![]() ![]() | |
Flash Player 5。
undefined
无。
无。
一个特殊值,通常用于指示变量尚未赋值。对未定义值的引用返回特殊值 undefined。动作脚本代码 typeof(undefined) 返回字符串 "undefined"。undefined 类型的唯一值就是 undefined。
在为 Flash Player 6 或更早版本发布的文件中,undefined.toString() 的值为 "" (空字符串)。 在为 Flash Player 7 或更高版本发布的文件中,undefined.toString() 的值为 undefined。
undefined 值与特殊值 null 相似。使用相等运算符对 null 和 undefined 进行比较时,它们的比较结果为相等。
在此示例中,变量 x 尚未声明,所以其值为 undefined。在代码的第一部分,我们使用相等运算符 (==) 对 x 的值与值 undefined 进行比较,并将相应的结果发送到“输出”面板。在代码的第二部分,我们使用相等运算符对值 null 和 undefined 进行比较。
// x 尚未声明
trace ("The value of x is " + x);
if (x == undefined) {
trace ("x is undefined");
} else {
trace ("x is not undefined");
}
trace ("typeof (x) is " + typeof (x));
if (null == undefined) {
trace ("null and undefined are equal");
} else {
trace ("null and undefined are not equal");
}
下面的结果显示在“输出”面板中。
The value of x is undefined x is undefined typeof (x) is undefined null and undefined are equal
![]() ![]() | |