Oh, JavaScript, you silly sausage…

> NaN === NaN
false

> typeof NaN
'number'

¯\_(ツ)_/¯

* NaN stands for “not a number”

Follow

@aral NaN !== NaN is specified behaviour for IEEE floating point numbers, though, so that one's not JS' fault

@jack Well, heck, can we at least agree it’s someone’s fault? :)

It’s hard to make a case for x !== x

@aral @jack It's hard to make a case for Inf == Inf or NaN == NaN too.
@aral @jack

$ node
> Infinity == Infinity
true

And I can say that and still find faults with JS. 😁
Of course, that's not JS's fault either. IEEE-754 1.2.5 draft:

> Every NaN shall compare unordered with everything, including itself. Comparisons shall ignore the sign of zero (so +0 = −0). Infinite operands of the same sign shall compare equal.

web.archive.org/web/2018110103…

@clacke @aral btw if you want to have some fun with NaN and Inf, this is worth a watch: youtube.com/watch?v=5TFDG-y-EH

Sign in to participate in the conversation
Mastodon

My home on the Fediverse.