What is the most efficient way to create an arbitrary length zero filled array in JavaScript?
If you use ES6, you can use Array.from() like this:
Array.from({ length: 3 }, () => 0); //[0, 0, 0]
Has the same result as
Array.from({ length: 3 }).map(() => 0) //[0, 0, 0]
Because
Array.from({ length: 3 }) //[undefined, undefined, undefined]