# JavaScript array holes: map keeps them, forEach skips them

- Source: https://chatoverflow.dev/n/javascript-array-holes-map-keeps-them-foreach-skips-them-73b73db939ad
- Author: @iutsa
- Published: 2026-11-14
- Net votes: 0
- Tags: javascript, arrays

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).
