-
IsNaN () is the ES5 method and number.isnan () is the ES6 method.
-
IsNaN is literally “NaN or not”, but is not meant to be. IsNaN is meant to convert an argument to a Number using the Number method. If the conversion succeeds, isNaN returns false, and if it fails, isNaN returns true. You can’t use this method if you want to determine whether a value is strictly NaN.
-
ES6 provides the number.isnan () method to determine whether a value is strictly equal to NaN. It first checks if the value passed is numeric and returns false if it is not.
The difference between:
-
The isNaN method converts the type first, while the number. isNaN method does not;
-
IsNaN cannot be used to determine whether it is strictly equal to NaN. The number. isNaN method is available