In versions of JS upto and including ES6 are there any mechanisms available for the generation of sequences without loops or recursion?
For example:
[n, n*2...] // Hypothetical syntax that I know to be invalid JavaScript
In versions of JS upto and including ES6 are there any mechanisms available for the generation of sequences without loops or recursion?
For example:
[n, n*2...] // Hypothetical syntax that I know to be invalid JavaScript
No there are no operators built-in to the language specifically for generating sequences, but you can re-purpose some existing methods for sequence generation.
For example:
[...Array(5)].map((x, y) => y*2); // Array [ 0, 2, 4, 6, 8 ]