▲ The definitive way to create arrays with predefined length and filling values at github.com▼2 up and 1 down, posted by jfet97 1965 days ago 3 comments
stewartrule 1964 days ago. link 1 point ▲ ▼Why not use Array.from and/or Array.prototype.fill? :) Array.from({ length: 3 }, (_, i) => i) // [0, 1, 2] Array.from({ length: 3 }).fill(42) // [42, 42, 42] Array(3).fill(42) // [42, 42, 42]
stewartrule 1964 days ago. link 2 points ▲ ▼ah missed that, but personally I would rather use the "verbose" solution than installing another dependency.