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

208
Vistas
Better way to destruction items in array? Javascript

I need better way to create arrays

Check my code:

  const [first, second, third, four, ...others] = allItems;
 
  return (
    <div >
      {[first, second, third, four].map().
   </div> 
   )

I am using react but that is not important here.

I need to better a way to get first four item.

WHat is allItems?

This is array of object.

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

0

You can use slice():

The slice() method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items in that array. The original array will not be modified.

For example:

allItems.slice(0,4)

(And allItems.slice(4) for the others)

about 4 years ago · Juan Pablo Isaza Denunciar

0

I think what you're looking for is allItems.slice(0,4).

  return (
    <div >
      {allItems.slice(0,4).map()}.
   </div> 
   )
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