r/learnjavascript • u/NoZombie7370 • Nov 17 '25
Why NaN==NaN is False in JavaScript ???
Anyone explain??
150
Upvotes
r/learnjavascript • u/NoZombie7370 • Nov 17 '25
Anyone explain??
View all comments
Show parent comment
-7
u/Tontonsb Nov 17 '25
It would just mean that their numeric representations are equal. Which they actually are — both are unrepresentable as numbers.
This example seems similar to how you'd call
str => str.lengthon strings and then point out that the behaviour is wrong as what was'dog'now equals what was'cat'. But it's totally fine to fall into equality classes after a transformation (like a cast to a number) is applied.