4.42 typeof 运算符
typeof 是一种用于数据类型判定的单目运算符,它支持任意类型的操作数。其运算结果是标识操作数的数据类型的字符串值。
表 4.9 typeof 运算
| 数据类型 | typeof运算的结果 |
|---|---|
| 字符串型 | "string" |
| 数值型 | "number" |
| 布尔型 | "boolean" |
| null型 | "object" |
| undefined型 | "undefined" |
| Object型 | "object" |
| 函数 | "function" |
| XML(E4X) | "xml" |
对于标准的对象来说,typeof 运算的结果一定是 "object",不过对于非标准对象,结果则取决于其具体实现。

浙公网安备 33010602011771号