Array.prototype.myForEach = function (callback, thisArg = undefined) { if (typeof callback !== 'function') { throw new TypeError(`${callback} is not a function`); } let index = 0 const len = this.length while (index < len) { if (index in this) callback.call(thisArg, this[index], index, this) index++ } }
标签:function,index,myForEach,len,callback,thisArg From: https://www.cnblogs.com/zhenjianyu/p/17128778.html