数组的every方法
Array.prototype.MyEvery = function (callback) {
let flag = true;
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.MyEvery = function (callback) {
let flag = true;
for (let i = 0; i < this.length; i++) {
flag = callback(this[i], i, this);
if (!flag) break;
}
return flag;
};