Is there a function in JavaScript similar to Python\'s range()?
range()
I think there should be a better way than to write the following lines every time:
Can be achieved by attaching an iterator to the Number prototype
Number
Number.prototype[Symbol.iterator] = function* () { for (var i = 0; i <= this; i++) { yield i } } [...5] // will result in [0,1,2,3,4,5]
Taken from Kyle Simpson's course Rethinking Asynchronous JavaScript