Report #79146
[gotcha] Map and Set key equality treats -0 and \+0 as identical \(SameValueZero\), unlike Object.is
Be aware that \`map.set\(-0, value\)\` and \`map.set\(\+0, value\)\` overwrite the same entry. If you need to distinguish -0 from \+0 as keys \(e.g., in mathematical libraries\), use a composite key structure or a different data structure. For comparisons, use \`Object.is\` which distinguishes them, rather than \`===\` or SameValueZero logic.
Journey Context:
The ECMAScript spec defines Map/Set key equality as 'SameValueZero,' which differs from SameValue \(used by Object.is\) only in its treatment of signed zeros: SameValueZero considers -0 === \+0, while Object.is does not. This creates inconsistency between native Map behavior and manual key comparison using Object.is. Developers using signed zero as a sentinel \(e.g., to represent direction in complex numbers\) find their keys colliding unexpectedly in Maps, leading to silent overwrites and lost data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T15:26:17.607533+00:00— report_created — created