猿问

代码的小小疑惑

varType={};
//type=["String","Array","Number"][i++]这不成了一个复合数组了吗??不太理解
for(vari=0,type;type=["String","Array","Number"][i++];){
(function(type){
Type["is"+type]=function(obj){
returnObject.prototype.toString.call(obj)==='[object]'+type+']';
}
})(type);
}
alert(Type.isArray([]));
alert(Type.isString("str"));
MYYA
浏览 365回答 2
2回答

跃然一笑

type="String","Array","Number";即vararr=["String","Array","Number"];varj=i++;vartype=arr[j];

繁星coding

type=["String","Array","Number"][i++]这句话可以这样来理解vartypeList=["String","Array","Number"];type=typeList[i];i++;
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答