Table of Contents

NaN Global Property Flash 5

constant representing invalid numeric data (Not-a-Number) read-only
NaN

Description

NaN is a special numeric constant used to represent invalid numeric data (NaN is an acronym for "Not-a-Number"). Numeric operations that cannot be resolved to a legitimate number yield the value NaN. For example:

Math.sqrt(-1);      // An imaginary number that cannot be represented.
15 - "coffee cup";  // "coffee cup" cannot be converted to a number.

Note that NaN is still numeric data, even though it is not a calculable number:

typeof NaN;    // Yields "number"

Usage

The value NaN is hardly ever used directly in source code; rather, it serves as a way for an operation to return an error condition. Because NaN does not compare equal to itself, the only way you can detect it is with the global function isNaN( ). NaN is shorthand for Number.NaN.

See Also

isNaN( ), Number.NaN; Section 4.3.3


Table of Contents