Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Properties:NaN

From MDC


Contents

[edit] Summary

A value representing Not-A-Number.

Core Global Property
Implemented in: JavaScript 1.3
ECMA Version: ECMA-262

[edit] Syntax

NaN

[edit] Description

NaN is a property of the global object, i.e. it is a variable in global scope.

The initial value of NaN is Not-A-Number - the same as the value of Number.NaN.

NaN is always unequal to any other number, including NaN itself; you cannot check for the not-a-number value by comparing to Number.NaN. Use the isNaN function instead.

Several JavaScript methods (such as the Number constructor, parseFloat, and parseInt) return NaN if the value specified in the parameter can not be parsed as a number.

You might use the NaN property to indicate an error condition for your function that returns a number in case of success.

JavaScript prints the value Number.NaN as NaN.

[edit] See also

isNaN, Number.NaN