Report #16134
[gotcha] Array constructor with single numeric argument creates sparse array with holes instead of single-element array
Use array literals \[\] or Array.of\(\) instead of new Array\(n\); never rely on new Array\(\) for element initialization
Journey Context:
The Array constructor is overloaded: single numeric argument initializes length and creates empty slots \(holes\), while multiple arguments become dense elements. This causes \[empty × 3\] instead of \[3\], making map/forEach skip holes and creating silent data loss. Array.of\(\) was added to ES6 specifically to treat a single number as a value, not a length. The sparse array behavior dates to ES1 for performance reasons but is almost never what developers intend.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:53:27.884875+00:00— report_created — created