constobj={name:"jsCoder",skill:["es6","react","angular"],say:function(){for(vari=0,len=this.skill.length;i
2 回答
四季花海
TA贡献1811条经验 获得超5个赞
constobj={name:"jsCoder",skill:["es6","react","angular"],say:function(){this.skill.forEach(function(item,index){setTimeout(function(){console.log(index)console.log(item);},0)})},say2:function(){for(vari=0,len=this.skill.length;isetTimeout(function(i,item){ console.log(i);console.log(item);},0,i,this.skill[i]);}},say3:function(){constarr=this.skill.slice();leti=0;functionpop(){constitem=arr.shift();if(item){console.log(i);console.log(item);i++;setTimeout(pop,0);}}setTimeout(pop,0);}};obj.say();setTimeout(function(){obj.say2();},1000)setTimeout(function(){obj.say3();},2000)
慕尼黑的夜晚无繁华
TA贡献1864条经验 获得超6个赞
say:function(){varthat=this;for(vari=0,len=this.skill.length;i{ setTimeout(function(){console.log(i);console.log(that.skill[i]);}(i),0)console.log(i);}}
添加回答
举报
0/150
提交
取消