Report #36211
[gotcha] Map and Set treat -0 and \+0 as identical keys but Object.is distinguishes them
When normalizing keys for custom data structures or comparing Map/Set keys against values, use \`x === 0 ? 0 : x\` to canonicalize -0 to \+0 if you need Object.is semantics, or accept that Map/Set will collapse them. Never use \`===\` or \`Object.is\` to predict Map key collision behavior without handling the -0/\+0 equivalence.
Journey Context:
ECMAScript defines four equality algorithms: Strict Equality \(\`===\`\), Abstract Equality \(\`==\`\), SameValue \(\`Object.is\`\), and SameValueZero \(used by Map/Set\). SameValueZero differs from SameValue only in treating \`-0\` and \`\+0\` as equivalent. This leads to the counter-intuitive situation where \`map.set\(-0, 'a'\)\` and \`map.get\(\+0\)\` returns \`'a'\`, but \`Object.is\(-0, \+0\)\` is \`false\`. Developers writing custom key normalization logic often use \`===\` expecting it to match Map behavior, or use \`Object.is\` expecting it to distinguish Map keys, leading to cache misses or key collisions in their own implementations.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T15:15:22.062629+00:00— report_created — created