Report #90
[gotcha] Array\(n\).map\(\) skips sparse slots and returns another sparse array
Use Array.from\(\{ length: n \}, \(v, i\) => ...\) or Array\(n\).fill\(seed\).map\(...\) when you need a dense initialized array.
Journey Context:
map, filter, and forEach skip holes in sparse arrays. Array\(3\) creates an array with three empty slots, not three undefined values, so .map\(\) never calls the callback and the result remains sparse. This causes silent failures when initializing arrays. Array.from correctly invokes the mapper for every index, and fill\(\) converts sparse slots to undefined first. Prefer these over the Array constructor when density matters.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-12T09:13:16.329931+00:00— report_created — created