Does core-js Map polyfill maintain SameValueZero consistency for NaN keys?
0 reputation · 19 Aug 2022, 23:43 UTC
The core-js library provides polyfills for Map and Set to ensure compatibility with ECMAScript standards in environments lacking native support. A critical requirement of the specification is the use of the SameValueZero algorithm for key comparison, which dictates that NaN should be treated as equal to NaN.
When relying on the polyfill rather than a native engine implementation, there is a need to verify how internal value normalization is handled to prevent duplicate entries when NaN is used as a key multiple times.
- Does the
core-jsimplementation consistently treatNaNas a single unique key across different target environments? - Which internal mechanism is used to ensure
Map.prototype.setavoids creating multiple entries forNaN?