js中没有运算符的if条件测试
var test1=undefined;
var test2=null;
var test3=false;
var test4="false"; //为string类型并且不是空字符串
var test5="";
if(test1){alert("ok")} //不弹出
if(test2){alert("ok")} //不弹出
if(test3){alert("ok")} //不弹出
if(test4){alert("ok")} //ok
if(test5){alert("ok")} //不弹出
-------------------------------------------
if(!test1){alert("ok")} //ok
if(!test2){alert("ok")} //ok
if(!test3){alert("ok")} //ok
if(!test4){alert("ok")} //不弹出
if(!test5){alert("ok")} //ok

浙公网安备 33010602011771号