当前位置:首页 >> 网络编程

js判断是否为空和typeof的用法(详解)

(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"); 
} 

以上就是小编为大家带来的js判断是否为空和typeof的用法(详解)全部内容了,希望大家多多支持~