当Var1为null或undefined时,( !Var1 )会返回真。所以如果不需要区分null还是undefined,则可以直接使用( !Var1 )来做判断。
http://www.cftea.com/c/2007/04/YK4PY29JW82CZOVY.asp
亮点:
exp 为 undefined 时,也会得到与 null 相同的结果,虽然 null 和 undefined 不一样。注意:要同时判断 null 和 undefined 时可使用本法。
var
exp = null;
if (!exp)
{
alert("is null");
}
未知美人
HxLauncher: Launch Android applications by voice commands