Create an array with same element repeated multiple times
In ES6 using Array fill() method
console.log(
Array(5).fill(2)
)
//=> [2, 2, 2, 2, 2]
>>> Array.apply(null, Array(10)).map(function(){return 5})
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5]
>>> //Or in ES6
>>> [...Array(10)].map((_, i) => 5)
[5, 5, 5, 5, 5, 5, 5, 5, 5, 5]