有關(guān)js判斷undefined類型,使用typeof方法,typeof 返回的是字符串,其中就有一個是undefined。
js判斷undefined類型
1
2
3
4
|
if (reValue== undefined) { alert( "undefined" ); } |
發(fā)現(xiàn)判斷不出來,最后查了下資料要用typeof方法:
1
2
3
4
|
if ( typeof (reValue) == "undefined" ) { alert( "undefined" ); } |
typeof 返回字符串,有六種可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"。
在使用時一定要注意。