JS如何判断值(undefined、null、NAN)
-
undefined
var arg = undefined; if (typeof(arg) == "undefined") { alert("undefined"); }
-
null
var exp = null; if (!exp && typeof(exp)!="undefined" && exp!=0) { alert("is null"); }
-
NAN
isNaN(123) == false isNaN("helloworld") == true