(1)typeof用法
typeof的运算数未定义,返回的就是 "undefined".
运算数为数字 typeof(x) = "number"
字符串 typeof(x) = "string"
布尔值 typeof(x) = "boolean"
对象,数组和null
函数 typeof(x) = "function"
(2)js判断是否为空
var exp = null;
if (!exp && typeof(exp)!="undefined" && exp!=0 && exp!='')
{
alert("is not null");
}
本文介绍了JavaScript中使用typeof进行变量类型的检测方法,并详细解释了如何判断一个变量是否为空,包括null、undefined、0及空字符串等特殊情况。
1234

被折叠的 条评论
为什么被折叠?



