Course recommendation:

JavaScript Number NaN property

is the abbreviation for "Not-a-Number".NaN Definition and usage

is the abbreviation for "Not-a-Number".NaN In JavaScript,

is an invalid number. NaN global property and Number.Nan

property is the same.

The NaN property is a special value representing non-numeric values. This property is used to indicate that a value is not a number. You can set the Number object to this value to indicate that it is not a numeric value.Tip: isNaN() Please use

Global function to determine whether a value is a NaN value.

See also:

Global isNaN() method

Number.isNaN() method

Example

let x = NaN;

let x = Number.NaN;

let x = NaN;

Try it yourself

Number.NaN

syntax

Number.NaN indicates It is a special value that indicates that the result of some arithmetic operations (such as the square root of a negative number) is not a number. The method parseInt() and parseFloat() Number.NaN to indicate its error conditions. When it cannot parse the specified string, it returns this value. This method can also be used for functions that return valid numbers in some common cases, such as

JavaScript uses NaN is output in the form of Number.NaN. Please note thatNaN The result of comparing with other numeric values is always not equal, including itself. Therefore, it cannot be compared with Number.NaN Comparison is used to detect whether a value is a number, and only isNaN() for comparison.

In ECMAScript v1 and subsequent versions, predefined global properties can also be used NaN Instead of Number.NaN.

Browser support

Number.NaN It is an ECMAScript1 (ES1) feature.

All browsers fully support ES1 (JavaScript 1997):

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support Support Support Support Support Support