JavaScript中typeof用法

来源:互联网 发布:ppt网络变压器 编辑:程序博客网 时间:2024/05/05 13:15
  1. typeof 的运算数未定义,返回的就是 “undefined”.

  2. 运算数为数字 typeof(x) = “number”

  3. 字符串 typeof(x) = “string”

  4. 布尔值 typeof(x) = “boolean”

  5. 对象,数组 和null typeof(x) = “object”

  6. 函数 typeof(x) = “function”

判断对象是否为空:object==‘’ || object == null || !typeod(object) == ”undefined“

0 0
原创粉丝点击