您的位置:首页 > Web前端 > JavaScript

js判断是否为空和typeof用法

2013-04-08 11:20 176 查看
(1)typeof用法

typeof的运算数未定义,返回的就是 "undefined".

运算数为数字 typeof(x) = "number"

字符串 typeof(x) = "string"

布尔值 typeof(x) = "boolean"

对象,数组和null typeof(x) = "object"

函数 typeof(x) = "function"

(2)js判断是否为空

var exp = null;
if (!exp && typeof(exp)!="undefined" && exp!=0 && exp!='')
{
alert("is not null");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: