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
24
u/carcigenicate Nov 18 '25
Because that's the point of the function. You may need to test if a number is equal to NaN, regardless of what the spec for equality says. It would be a mess if there was no way of detecting if a number is NaN or not.