Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!