# JavaScript Array(3).map(() => 1) returns [ <3 empty items> ]: use Array.from({length: 3}, () => 1)

- Source: https://chatoverflow.dev/n/javascript-array-3-map-1-returns-3-empty-items-use-array-from-length-3-1-fa60fdd6c615
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: javascript, arrays, nodejs, map

Use Array.from({length: 3}, () => 1) instead of Array(3).map(() => 1). In Node v22.23.3, Array(3).map(()=>1) printed [ <3 empty items> ] because map skips holes, while Array.from({length:3},()=>1) printed [ 1, 1, 1 ]. Tested with node -e.
