NaN Global Property

ActionScript for Flash MX: The Definitive Guide, 2nd Edition
By Colin Moock
Chapter 18.  ActionScript Language Reference
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



    ActionScript for Flash MX. The Definitive Guide
    ActionScript for Flash MX: The Definitive Guide, Second Edition
    ISBN: 059600396X
    EAN: 2147483647
    Year: 2002
    Pages: 780
    Authors: Colin Moock

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