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

87
Views
How spread operator working here with Array keys

Could someone explain how this [...Array(10).keys()]; working and logging 0 to 9 index?

console.log([...Array(10).keys()]);

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Here is the explanation

Case-1

const string = 'hello';

const array = [...string];

array;
// [ 'h' , 'e', 'l', 'l', 'o' ]

Case-2

Where we see spread operator acting as an eraser

[
  ...[1, 2, 3] // The dots erases the brackets
]

/*  Becoming this: */
[
  1, 2, 3 // "Erased"
]

Combining both of the above cases will help you on whats happening

about 4 years ago · Santiago Trujillo 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!