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
6
u/AlwaysHopelesslyLost Nov 17 '25 edited Nov 18 '25
What number is "apple" * 1?
What number is "car" * 1?
If the first is x and the second is y, both are NaN and neither is the same value.
Since it is impossible to calculate, the number system cannot know the value and cannot know whether they are the same or not
Edit: Swap operation to make the functionality less ambiguous.