Report #15191
[gotcha] Array constructor with single numeric argument creates sparse array instead of \[value\]
Never use \`new Array\(n\)\` for initialization; use \`Array.from\(\{ length: n \}\)\` or \`\[...Array\(n\)\]\` if you need an iterable of length n, or literal \`\[value\]\` for single elements. Always pass a radix or use \`Array.of\(\)\` for multiple arguments.
Journey Context:
The \`Array\(len\)\` constructor overload creates a sparse array with \`length\` set to \`len\` but no elements \(empty slots\). This is distinct from \`Array.of\(3\)\` which creates \`\[3\]\`. The footgun appears when developers expect \`new Array\(3\)\` to yield \`\[3\]\`, then call \`.map\(\)\` and find it doesn't execute because empty slots are skipped by iteration methods. This is a legacy design from ES1 for pre-allocating arrays. Modern alternatives avoid the sparse array trap entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:22:37.051588+00:00— report_created — created