Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

209
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda