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