Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

130
Vistas
Is there a way to get a range of indexes from a javascript array?

I am trying to find a way to get a range of 5 sequential indexes from an array of indeterminate length.

My array might look like this: [0,1,2,3,4,5,6,7]

I know I can use array.slice() if I need to return something like [2,3,4,5,6], but sometimes I might need to return something like [6,7,0,1,2]

Is there a clean or built-in way to do this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If I understood right, you need something like this:

function array_indexes(arr, keys){
    let res = [];
    for(let k of keys){
        res.push(arr[k]);
    }
    return res;
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda