var s=""
if(s){
//s不是空字符串
}else{
//s是空字符串
}
一般判断为空有 null值、undefined值与NaN值判断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"
=:全等或恒等全等检查(===)