Skip to content

Comment on Speaking JavaScriptparent

Comments

The reason is simple:

"hello" is Not a Number. "world" is Not a Number.

(Number)"hello" == (Number)"world" returns false.

EDIT: Another reason why this is the case is because IEEE mandates it to be. All numbers in JS are 64 bit floating point numbers. This allows for a crazy amount of NaNs (and oh the fun stuff you can do with that). To be sane, NaNs are not the same when comparing them (there is a lot more subtlety in that - comparing quiet and signalling NaNs, and so on and so forth)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.