News for hackers. Stuff that matters.
Re:JavaScript at 20 by TazeTSchnitzel on Friday May 15, 2015 @02:07PM (#9552463)
I think I can. The old isNaN() coerces to Number, and non-numeric strings become NaN in JS, e.g. +"LOL" is NaN. However, the new isNaN() just returns false if the value passed isn't of the type Number, which I guess might be useful if you're going to use isNaN() on non-Number values?

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.

Re:JavaScript at 20 by magicalist on Friday May 15, 2015 @02:17PM (#9552541)
note that isNaN() will remain as it is today, coercing to a number (and so isNaN('LOL') will continue to return true). Number.isNaN() will have the new behavior, testing for actual IEEE 754 NaN values (and so returning false for Number.isNaN('LOL')). Such is the unfortunate price of backwards compatibility.