DEV Community

Discussion on: Five powerful JavaScript array methods.

Collapse
 
itsjzt profile image
Saurabh Sharma
Array(10).fill(null).map(_, i => i)
Enter fullscreen mode Exit fullscreen mode

This creates an array of the given range 10 in this case. I use this all the time

Collapse
 
taslangraham profile image
Taslan Graham

Wow!
I've never used this before. Will give it a try soon.

Collapse
 
1987cr profile image
Carlos Riera

Shorter alternative :)

[...Array(10).keys()]
Enter fullscreen mode Exit fullscreen mode
Collapse
 
itsjzt profile image
Saurabh Sharma

Oh nice,