DEV Community

Discussion on: Another way to write your JavaScript

Collapse
 
thematrixan profile image
Mateusz Lesiak • Edited

Generate an array of sequential numbers [1, 2, 3, ...., n]

You can achieve that also with this:

[...Array(5)].map((n, i) => i) // (5) [0, 1, 2, 3, 4]
Collapse
 
zeyadetman profile image
Zeyad Etman

Yes, but this case I talked about it in the first section, it creates an array of empty values. which is slow when you do operations over it.