数组的forEach方法
Array.prototype.MyForEach = function (callback) {
for (let i = 0; i < this.length; i++) {
callback(this[i], i, this);
}
};
1
2
3
4
5
2
3
4
5
Array.prototype.MyForEach = function (callback) {
for (let i = 0; i < this.length; i++) {
callback(this[i], i, this);
}
};