Report #6546
[gotcha] Array methods skip or produce unexpected results on sparse arrays created with new Array\(n\)
Use Array.from\(\{length: n\}, \(\_, i\) => i\) or literal \[\] with push/spread. If you must use new Array\(n\), fill it with .fill\(undefined\) before mapping, or use Array.from to map over indices
Journey Context:
new Array\(3\) creates a sparse array with empty slots \(holes\), not \[undefined, undefined, undefined\]. .map\(\), .forEach\(\), .filter\(\) skip holes. This breaks initialization code like new Array\(5\).map\(\(\) => \[\]\) which returns a sparse array of holes because map skips empty slots. The fix uses Array.from which visits every index or fills then maps, trading memory for predictable density.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T00:19:23.090572+00:00— report_created — created