I\'m looking for any alternatives to the below for creating a JavaScript array containing 1 through to N where N is only known at runt
1
N
Iterable version using a generator function that doesn't modify Number.prototype.
Number.prototype
function sequence(max, step = 1) { return { [Symbol.iterator]: function* () { for (let i = 1; i <= max; i += step) yield i } } } console.log([...sequence(10)])