Report #76347
[gotcha] Map/Set keys treat -0 and \+0 as identical but NaN as equal to itself unlike ===
Use Object.is\(\) to distinguish -0 from \+0; expect NaN to work as a valid key in Map/Set despite NaN \!== NaN
Journey Context:
Developers expect strict equality \(===\) semantics for collection keys. Map and Set use the SameValueZero algorithm: -0 and \+0 are treated as the same key \(collapsing signed zero\), but critically NaN is treated as equal to itself \(unlike === where NaN \!== NaN\). This breaks uniqueness assumptions for numeric keys and can cause silent key collisions when using computed values that might produce -0 \(e.g., Math.round\(-0.5\)\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T10:44:47.206550+00:00— report_created — created