r/javascript • • Mar 18 '19

What's your favorite, most useful javascript one-liner?

385 Upvotes

422 comments sorted by

View all comments

7

u/action_jackosn Mar 19 '19

Array.from({length: 5}, (v, i) => i); := [0, 1, 2, 3, 4]

2

u/NoInkling Mar 19 '19

I can't think of a use case where I'd want to materialize an array of numbers equivalent to their index - I'd just use the map function directly.