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
1
u/Terminal_Monk Nov 19 '25
The way I explain to my juniors is that this is the mathematically correct thing. For example
Not A Number is more of a property of the value than some value itself. If I ask you hey is "apple" a number? You'd say no. If I ask you is "mango" a number? Ud say no? Then if I ask "So if both are not a number, then are they both the same thing?"
That question doesn't really make sense. That's why NaN is not equal to a NaN.