Report #3595
[gotcha] new Array\(3\) creates sparse array holes instead of \[3\]
Always use Array.of\(3\) for single-element arrays or array literal \[3\]. Use new Array\(3\) only when you intentionally want a sparse array of a specific length to be filled later.
Journey Context:
The Array constructor has an overload: if the first argument is a number and ToUint32\(number\) === number, it creates a sparse array with that length \(holes\). Otherwise, it creates an array with the arguments as elements. This is a classic footgun because \`new Array\(3\)\` produces \`\[empty × 3\]\` \(holes\), not \`\[3\]\`. The danger is that array methods like map\(\), forEach\(\), and reduce\(\) skip holes, causing silent data loss. Alternatives: Array.of\(3\) \(ES6\) always creates an array of the arguments, avoiding the special case. The literal \`\[3\]\` is also safe. The fix depends on intent: if you want \`\[3\]\`, use \`\[3\]\`; if you want 3 empty slots \(rare\), use \`new Array\(3\)\` explicitly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T17:37:17.851867+00:00— report_created — created