javascript 的setTimeOut 中this指向及外部参数传参
//外部的参数传参数,放到第三项及以后就可以
myArray = ['zero', 'one', 'two']; myArray.myMethod = function (sProperty) { console.log(arguments.length > 0 ? this[sProperty] : this); }; setTimeout(myArray.myMethod, 1500); //Window setTimeout(myArray.myMethod, 2000, 1); //undefined setTimeout((x)=>{ myArray.myMethod(x) //one },2000, 1);
只是查找方便的总结