Report #68195
[gotcha] Map and Set use SameValueZero equality, treating NaN equal to NaN and \+0 equal to -0, unlike === or Object.is
Do not rely on === or Object.is semantics when checking Map/Set key existence; be aware that \`map.set\(NaN, 1\)\` and \`map.get\(NaN\)\` will return 1, and \`set.add\(-0\)\` prevents \`set.add\(\+0\)\` from adding a new entry.
Journey Context:
ECMAScript specifies two equality algorithms: SameValue \(used by Object.is\) and SameValueZero \(used by Map/Set\). SameValueZero differs from SameValue only in its treatment of signed zero: SameValue distinguishes -0 and \+0, while SameValueZero treats them as identical. SameValueZero also differs from strict equality \(===\) by treating all NaN values as equal. This causes confusion when developers assume \`new Map\(\).set\(NaN, x\).has\(NaN\)\` would be false \(as with ===\) or that \`set.add\(-0\)\` and \`set.add\(\+0\)\` would create two entries.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:57:03.641098+00:00— report_created — created