what is the difference between isNaN and Number.isNaN?
isNaN('hello world'); // returns 'true'.
Number.isNaN('hello world'); // returns 'false
what is the difference between isNaN and Number.isNaN?
isNaN('hello world'); // returns 'true'.
Number.isNaN('hello world'); // returns 'false
The spec is a good place to turn for this kind of subtlety. isNaN
tries to convert its argument to a number; Number.isNaN
doesn't, it returns false if the type of its argument isn't "number"
. So:
console.log(isNaN("%")); // true, coerced to number and result was NaN
console.log(Number.isNaN("%")); // false, not coerced