1. 程式人生 > 其它 >js判斷undefined和null

js判斷undefined和null

技術標籤:jsjavascriptwebmybatishtml

js判斷undefined

var exp = undefined;
if (typeof(exp) == "undefined")
{
    alert("undefined");
}

js判斷null

var exp = null; 
if (!exp && typeof(exp)!=”undefined” && exp!=0) 
{ 
alert(“is null”); 
}

js判斷null和undefined

var exp = undefined;
if (typeof(exp) == undefined)
{
    alert("undefined");
}