javascript typeof的用法
typeof 运算符 返回一个用来表示表达式的数据类型的字符串。
typeof )expression
] ;
expression 参数是需要查找类型信息的任意表达式 。
http://book.csdn.net/bookfiles/110/1001103362.shtml
ps:js设计的一个小错误,请主意。
原始类型、引用类型 :http://book.csdn.net/bookfiles/110/1001103364.shtml
这本书可以看看:http://book.csdn.net/bookfiles/110/#c1
说明 typeof 运算符把类型信息当作字符串返回。typeof 返回值有六种可能: "number," "string," "boolean," "object," "function," 和 "undefined."
typeof 语法中的圆括号是可选项。
typeof的结果只有可能是'number','string','boolean','function','object','undefined'。new 生成的对象typeof为object。 instanceof右边一定是Number,String,Boolean,Function,Object,自定义函数对象。 .constructor的结果也只可能是Number,String,Boolean,Function,Object,自定义函数对象。 且Number,String,Boolean,Function,Object,自定义函数对象,她们的.constructor都是Function,typeof 她们 == 'function'。
掌握javascript的prototype链原理及{}.prototype为null//undifined 但是请主意Object.prototype为“object” 因为typeof Object 为"function",由此可见所以可以使用new的关键字或自定义函数, 如
new Number (),new String (),new Boolean (),new Function (),new Function (),他们都是函数类型。