Flash Null, undefined, nan, "" These three special values are very easy to make mistakes, but everyone can see their differences from the following statements: var ddd0: string;
Var ddd1: string = null;
VAR DDD2: String = undefined;
VAR DDD3: String = nan;
VAR DDD4: STRING = "";
TRACE ("DDD0 =" DDD0);
// Output: undefined
Trace ("DDD1 =" DDD1);
// Output: NULL
TRACE ("DDD2 =" DDD2);
// Output: undefined
TRACE ("DDD3 =" DDD3);
// Output: undefined
TRACE ("DDD4 =" DDD4);
// Output:
VAR DDD5: String = "233.2";
TRACE ("DDD0 =" Number (DDD0));
// output: nan
Trace ("DDD1 =" Number (DDD1));
// output: nan
TRACE ("DDD2 =" Number (DDD2));
// output: nan
TRACE ("DDD3 =" Number (DDD3));
// output: nan
TRACE ("DDD4 =" Number (DDD4));
// output: nan
TRACE ("DDD5 =" Number (DDD5));
//output:233.2--------------------------------------------- ---------------------- Yesterday, read the help of Flash carefully, and found the following from "Flash Help" NULL.
The null data type has only one value, ie NULL. This value means "no value", that is, the lack of data. NULL values can be used in a variety of situations. Here are some examples:
· Indicates that the variable has not received a value
· Indicates that variables no longer contain values
· As the return value of the function, the indication function does not have a value that can be returned.
· As the parameters of the function, indicate a parameter
Undefined undefined data types have a value, namedefined, which is used for variables that have not been assigned values.
Nan
Usability
Flash Player 5.
usage
Nan
Description
Variables; represents a predefined variable having a nan (non-numeric), IEE-754 standard value. To determine if a number is NAN, use Isnan (). If the unlessned variable (as shown in the following example), the value of the variable will be nan or undefined
Var Squared = x * x; trace (Squared); //out.print:nan
VAR x = 6; var DDD_STR = XY_STR; trace (ddd_str); //out.print:undefined
Trace (D_STR); //out.print:undefined