数组的findIndex方法
Array.prototype.MyFindIndex = function (callback) {
for (let i = 0; i < this.length; i++) {
if (callback(this[i], i, this)) {
return i
}
}
return -1
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Array.prototype.MyFindIndex = function (callback) {
for (let i = 0; i < this.length; i++) {
if (callback(this[i], i, this)) {
return i
}
}
return -1
}