Nan, meaning not a nnmber. The main purpose of introducing this numeric type variable in Javascript is to control the situation where "a number is returned but no number is returned. For example, if a number is divided by 0, errors may occur in many other languages, but Nan is returned in JavaScript. This does not affect the process.
Nan has two features: First, any operation involving Nan will return Nan, and second, Nan is not equal to any value, including Nan itself.
For Nan, ecmascript specifies the isnan () function to determine whether it is a number. Let's look at several examples:
In the example, we can see that isnan () will try to convert the passed non-numeric parameter to the numeric type, and return true if such conversion is not possible.
In addition, it should be emphasized that isnan () can operate on objects. When the parameter is an object, the system will try to call the valueof () method of the object and determine whether the returned value can be converted to a value. If the tostring () method cannot be called, the system will test the return value.
The basic process for isnan () operations is as follows:
References: javascript advancedProgramDesign