//var a;
b = null;
var c = 10;
delete c;
if (a == null) {
trace("a is null");
} if (a == undefined) {
trace("a is undefined");
}
if (b == null) {
trace("b is null");
}
if (b == undefined) {
trace("b is undefined");
}
if (c == null) {
trace("c is null");
} if (c == undefined) {
trace("c is undefined");
}
if (a == null and a == undefined) {
trace("typeof a "+typeof a);
}
if (b == undefined and b == null) {
trace("typeof b "+typeof b);
}
if (c == undefined and c == null) {
trace("typeof c "+typeof c);
}
所有結果都是true,trace會輸出,undefined和null是沒有分別的。
但打開Debug Panel,只有b剩下:
如果將==改為!=,例如:
//var a;
b = null;
var c = 10;
delete c;
if (a != null) {
trace("a is null");
}
if (a != undefined) {
trace("a is undefined");
}
if (b != null) {
trace("b is null");
}
if (b != undefined) {
trace("b is undefined");
}
if (c != null) {
trace("c is null");
}
if (c != undefined) {
trace("c is undefined");
}