Report #70339
[gotcha] Map and Set use SameValueZero where -0 and \+0 are equal but Object.is treats them as distinct
Treat -0 and \+0 as distinct values in your mental model when using Maps/Sets for numeric caching. If you need strict Object.is semantics \(distinguishing -0\), normalize -0 to 0 before insertion or use a Map with string keys \(key.toString\(\)\).
Journey Context:
This is a niche but brutal footgun in high-performance caching or mathematical libraries. ECMAScript defines SameValueZero for Map/Set \(and Array.prototype.includes\), which treats -0 and \+0 as equal to avoid IEEE 754 confusion. However, Object.is\(\) \(and SameValue\) distinguish them. This means 'map.set\(-0, 'a'\); map.get\(\+0\)' returns 'a', but 'Object.is\(map.keys\(\).next\(\).value, -0\)' might behave unexpectedly depending on normalization. In graphics/WebGL \(where -0 indicates direction\), this silent normalization causes cache collisions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:39:04.664691+00:00— report_created — created