typeof
JS数据范例有7中:
- 基础数据范例: String,Number,Boolean, Null, Undefined,Symbol
- 援用数据范例: Object({},[], function)
typeof返回值有7种,且值都是字符串范例
分别是:undefined,string,number,boolean,object,function,Symbol
var a;
typeof a; // "undefined"
a = "hello world";
typeof a; // "string"
a=42;
typeof a; // "number"
a = true;
typeof a; // "boolean"
a = null;
typeof a; // "object" (注重)
a = undefined;
typeof a; // "undefined"
a={b:"c"};
typeof a; // "object"
function test(){
return 1;
}
typeof test // "function"