javascript typeof 运算符的使用方法

作者:简简单单 2011-05-15

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

typeof[()expression[]] ;

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

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

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


var sTemp = "test string";
alert(typeof sTemp);
alert(typeof 95);


看个详细的实例


   
      Using typeof to determine the type of variables
   
   
   
   
   
   

相关文章

精彩推荐