Code
var cool = new Array(3); cool[setAll] = 42; //cool[setAll] is just a pseudo selector.. alert(cool);
Result
The ES6 approach is very clean. So first you initialize an array of x length, and then call the fill method on it.
fill
let arr = new Array(3).fill(9)
this will create an array with 3 elements like:
[9, 9, 9]