判断undefined:
var tmp = undefinedif (typeof(tmp) == "undefined"){ alert("undefined")}
说明:typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"
判断null:
var tmp = nullif (!tmp && typeof(tmp)!="undefined" && tmp!=0){ alert("null")}
判断NaN:
var tmp = 0/0if(isNaN(tmp)){ alert("NaN")}
附上全部相等图≅:松散等于等于检查(==), 比如: "1" == true[] =="0"
=:全等或恒等全等检查(===)
var a = ""if (a =="" ||undefined || null) {
alert("数据为空")
}else{
alert("数据正确")
}
这样就可以!希望能帮到你~