javascript之typeof

来源:互联网 发布:悬臂式货架 网络报价 编辑:程序博客网 时间:2024/05/23 00:04

typeof 运算符的用法

返回一个用来表示表达式的数据类型的字符串。

typeof[()expression[]] ;

expression 参数是需要查找类型信息的任意表达式

说明

typeof 运算符把类型信息当作字符串返回。typeof 返回值有六种可能: "number," "string," "boolean," "object," "function," 和 "undefined."

typeof 语法中的圆括号是可选项。


typeof的运算数及返回值说明

为未定义,返回的就是 "undefined".

数字 typeof(x) = "number"

字符串 typeof(x) = "string"

布尔值 typeof(x) = "boolean"

对象,数组和null typeof(x) = "object"

函数 typeof(x) = "function"


本文转自:http://blog.csdn.net/rocky_j2ee/article/details/3855078


原创粉丝点击