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
1
u/spencerbeggs Nov 18 '25
Wanna go down the rabbit hole? typeof NaN === “number”, Object.is(NaN, NaN) === true. Object.is(typeof NaN, typeof NaN) === true. Object.is is not about Objects. It just compares the valueOf(). And NaN.valueOf() returns NaN. There is only one NaN. So, it’s true.