Report #58879
[gotcha] Map keys -0 and \+0 considered identical causing key collision
Use Object.is\(key, -0\) before insertion if distinguishing zero signs is required, or use a string representation key
Journey Context:
Map and Set use SameValueZero algorithm for key equality. SameValueZero treats -0 and \+0 as equal \(unlike Object.is which treats them as different\). If you need to distinguish negative zero \(e.g., in mathematical libraries maintaining signed zeros per IEEE 754\), Map will collapse them. SameValueZero also treats NaN equal to NaN \(unlike ===\). This is specified in ECMA-262. The solution is to pre-process keys if zero sign matters, or use a library that supports signed zero keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:19:01.081801+00:00— report_created — created