Javascript - Map Keys Equality


Key equality in Map() is based on the "same-value" algorithm.

It is similar to the === operator but also considers NaN to be equal to NaN (even though generally NaN !== NaN).

You can use NaN as a key to store and retrieve value.

let myMap = new Map(); 
myMap.set(NaN, "not a number"); 
myMap.get(NaN); // "not a number" 

Related Topic