Report #53229
[gotcha] Array\(n\).map\(\) skips holes and returns empty array instead of transformed values
Use Array.from\(\{ length: n \}, \(v, i\) => ...\) or Array\(n\).fill\(0\).map\(...\) to ensure dense arrays before mapping. Never use new Array\(n\).map\(\) expecting iteration.
Journey Context:
The Array constructor with a single numeric argument creates a sparse array with empty slots \(holes\), not undefined values. Array.prototype.map skips holes entirely \(per spec step 4.c.iii checking HasProperty\), so the callback never executes. Array.from treats array-like objects differently by actually accessing indices 0..n-1, creating a dense array. This distinction between sparse and dense arrays is invisible in length but crucial for iteration.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:50:36.149078+00:00— report_created — created