On Thursday, during my JavaScriptHours stream, we came across something interesting.
In JavaScript, NaN !== NaN
. With a Set
, the values are unique. If you try to add the same value, there will always be one of it in the Set
.
During the stream, I created a Set
and added NaN
to it twice. Some of the audience in the chat as well as myself were surprised and perplexed that the Set
contained one value after adding NaN
twice given that NaN !== NaN
.
Does anyone know why this is? My only guess is that maybe there is a Symbol
that indicates NaN
is unique even though NaN !== NaN
.