Report #51969
[gotcha] Map and Set treat -0 and \+0 as identical \(SameValueZero\), unlike Object.is\(\)
If you must distinguish -0 and \+0 as keys \(e.g., for mathematical direction-sensitive caching\), use a string key like \`key === 0 ? 1/key : key\` or normalize to a custom object. Otherwise, normalize -0 to \+0 before insertion.
Journey Context:
\`Object.is\(-0, \+0\)\` returns \`false\`, leading developers to assume Map keys share this behavior. However, Map and Set use \`SameValueZero\` equality, which differs from \`SameValue\` \(used by \`Object.is\`\) only in treating \`-0\` and \`\+0\` as equivalent. This causes bugs when using signed zero as a sentinel value in geometric or thermodynamic calculations stored in Maps. The ECMAScript spec mandates this for consistency with \`Array.prototype.indexOf\`. There is no flag to change this; applications requiring distinct zero keys must encode the sign manually.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:43:20.303524+00:00— report_created — created