您的位置:首页 > 其它

利用typeof来进行判断得到的变量是否为null(undefined)

2017-06-27 08:40 267 查看
- var exp = undefined;
- if (typeof(exp) == "undefined")
- {
-     alert("undefined");
- }


注意判断是否是undefined的时候一定要在两边加上引号,否则不成功(个人测试结果!)

typeof 返回的是字符串,有六种可能

:”number”、”string”、”boolean”、”object”、”function”、”undefined”
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: