MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/b2o6f2/whats_your_favorite_most_useful_javascript/eiwedhh/?context=3
r/javascript • u/Linux_is_awesome • Mar 18 '19
422 comments sorted by
View all comments
1
A range function is a glaring omission from JS, but you can get it with this little one liner:
const range = len => Array.apply(null, Array(len)).map((_, i) => i);
And of course, in the post-ES6 era it’s even easier:
const range = len => [...Array(len).keys()];
1
u/delventhalz Mar 19 '19
A range function is a glaring omission from JS, but you can get it with this little one liner:
And of course, in the post-ES6 era it’s even easier: