by wppick · 11y ago · 0 comments
I would expect isNaN("LOL") to be true. Why does he put "true?!", and why does Number.isNaN("LOL") evaluate to false?
Adding a new, proper isNaN function under a new namespace (Number) lets them do that without breaking the old functionality.
Before someone says that NaN means "not a number", technically yes it does, but it is really just a special value of the Number type.
Edit: Oh, zastavka's comment has enlightened me now. I think the reason they changed it is because now it'll check if it's NaN (return true) or anything else (return false), so it'd be like === NaN if you were able to do that. Previously it'd check if it coerces to NaN. I guess the new behaviour is more intuitive.
Personally I don't see how this solves much, but then again I'm not a JavaScript guy.
Standard NaN is even weirder: http://en.m.wikipedia.org/wiki/NaN