ECMAScript中有五种基本数据类型:Undefined, Null, Boolean, Number, String,一种复杂数据类型:Object
数据类型检测方法
typeof 函数,例:
1 | var s = xx; |
| 返回结果=typeof(res) | 意义 |
|---|---|
| typeof(res) === “undefined” | 值未定义 |
| typeof(res) === “boolean” | 值为布尔类型 |
| typeof(res) === “string” | 值是字符串 |
| typeof(res) === “number” | 值为数值 |
| typeof(res) === “object” | 值是对象或null |
| typeof(res) === “function” | 值是函数 |