Is there a mechanism to loop x times in ES6 (ECMAScript 6) without mutable variables?
Using the ES2015 Spread operator: […Array(n)].map() const res = […Array(10)].map((_, i) => { return i * 10; }); // as a one liner const res = […Array(10)].map((_, i) => i * 10); Or if you don’t need the result: […Array(10)].forEach((_, i) => { console.log(i); }); // as a one liner […Array(10)].forEach((_, i) => console.log(i)); Or … Read more