代码的小小疑惑
var Type={};
//type=["String","Array","Number"][i++]这不成了一个复合数组了吗??不太理解
for(var i=0,type;type=["String","Array","Number"][i++];){
(function(type){
Type["is"+type]=function(obj){
return Object.prototype.toString.call(obj)==='[object]'+type+']';
}
})(type);
}
alert(Type.isArray([]));
alert(Type.isString("str"));
BC245
9 years, 4 months ago