Name
NaN Global Property — constant representing invalid numeric data (Not-a-Number)
Availability
Flash 5
Synopsis
NaN
Access
Read-only
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 but rather 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 in Chapter 4
Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.