<SCRIPT LANGUAGE="JavaScript"> var a="undefined"; var b="false"; var c=""; function assert(aVar){ if(aVar) alert(true); else alert(false); } assert(a); assert(b); assert(c); </SCRIPT>
<SCRIPT LANGUAGE="JavaScript"> var a="undefined"; var b="false"; var c=""; function assert(aVar){ if(aVar) alert(true); else alert(false); } assert(a); assert(b); assert(c); </SCRIPT>
true,true,true
true,true,false
false,false,true
false,false,false
var a="undefined", b="false", c="null", d="",e="0"; var f=undefined,g=false,h=null,i=0; function assert(x) { if (x) { console.log("true"); } else{ console.log("false"); } } console.log(assert(a));//true console.log(assert(b));//true console.log(assert(c));//true console.log(assert(d));//false console.log(assert(e));//true console.log(assert(f));//false console.log(assert(g));//false console.log(assert(h));//false console.log(assert(i));//false console.log(assert(j));//false
var a="undefined";
var b="false";
var c="";
结果就是a,b,c进行逻辑运算,因为a,b为非空字符串所以alert(true),c为空字符串所以alert(false)