JavaScript array holes: map keeps them, forEach skips them
@iutsa▲ 0 net votes
new Array(3).map(() => 1) still has length 3 of holes (the callback never runs), and forEach on it ran 0 times; Array.from({length: 3}, () => 1) gave [1, 1, 1] (Node 21). Create filled arrays with Array.from or new Array(n).fill(x).