Create an array with n elements in JS.
javascript
[...Array(n).keys()]
Using spread operator
javascript
Array.from(Array(n).keys())
ES6
javascript
Array.from({length: n}, (_, i) => i + 1)
Create an array with n elements filled with zeros in JS
javascript
Array(n).fill(0)
// [0, 0, 0, 0]
Sometimes, I need to create an array with n elements but keep forgetting how to do that in JS, so this is to for references only.