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