Section 24.131. Number.NaN: the special not-a-number value


24.131. Number.NaN: the special not-a-number value

ECMAScript v1

24.131.1. Synopsis

 Number.NaN 

24.131.2. Description

Number.NaN is a special value that indicates that the result of some mathematical operation (such as taking the square root of a negative number) is not a number. parseInt( ) and parseFloat( ) return this value when they cannot parse the specified string, and you might use Number.NaN in a similar way to indicate an error condition for some function that normally returns a valid number.

JavaScript prints the Number.NaN value as NaN. Note that the NaN value always compares as unequal to any other number, including NaN itself. Thus, you cannot check for the not-a-number value by comparing to Number.NaN; use the isNaN( ) function instead. In ECMAScript v1 and later, you can also use the predefined global property NaN instead of Number.NaN.

24.131.3. See Also

 isNaN( ), NaN 




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net