var exp = 0;
if (!exp)
{
alert(“is null”);
}
注意:要同时判断 null、undefined 和数字0时可使用本法
var exp = null;
if (!exp && typeof(exp)!=“undefined” && exp!=0)
{
alert(“is null”);
}
JS 中如何判断 null
typeof 返回的是字符串,有六种可能:“number”、“string”、“boolean”、“object”、“function”、“undefined”
var exp = undefined;
if (typeof(exp) == “undefined”)
{
alert(“undefined”);
}
undefined 的判断