龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > Javascript编程 >

使用typeof方法判断undefined类型

时间:2014-09-10 12:07来源:网络整理 作者:网络 点击:
分享到:
使用typeof方法,typeof 返回的是字符串,其中就有一个是undefined,下面是示例代码,大家可以看看

有关js判断undefined类型,使用typeof方法,typeof 返回的是字符串,其中就有一个是undefined。

js判断undefined类型

if (reValue== undefined)
{
alert("undefined");
}

发现判断不出来,最后查了下资料要用typeof方法:

if (typeof(reValue) == "undefined")
{ 
alert("undefined");
}

typeof 返回字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"。
在使用时一定要注意。

精彩图集

赞助商链接