function type(target){ var ret=typeof(target);
//引用值类型可以判断是数组,对象还是包装类 var template={ "[object Array]":"array", "[object Object]":"object", "[object Number]":"number-object", "[object Boolean]":"boolean-object", "[object String]":"string-object" } if(target===null){ return null; } if(ret=="object"){ var str=Object.prototype.toString.call(target); return template[str]; }else{ return ret; } } type(new Number())