Report #26500
[gotcha] Array\(n\).map\(\) creates empty slots that cause map/forEach to skip execution
Use \`Array.from\(\{length: n\}, \(v, i\) => ...\)\` or \`Array\(n\).fill\(\).map\(\(\_, i\) => ...\)\` to ensure the array has actual undefined values rather than empty slots.
Journey Context:
The Array constructor with a single number argument creates a sparse array with empty slots \(holes\). Array.prototype.map explicitly skips holes \(as does forEach, every, etc.\), so \`new Array\(5\).map\(\(\) => 1\)\` returns an array of 5 empty slots, not \[1,1,1,1,1\]. This bites when dynamically creating placeholder arrays or data grids. The fix leverages \`Array.from\` which does not preserve holes, or explicitly fills the array first.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:53:00.208579+00:00— report_created — created