default array values

You can use the fill function on an array:

Array(24).fill(0)

Note: fill was only introduced in ECMAScript 2015 (alias “6”), so as of 2017 browser support is still very limited (for example no Internet Explorer).

Leave a Comment