数组的filter方法
  Array.prototype.MyFilter = function (callback) {
	const res = [];
	for (let i = 0; i < this.length; i++) {
		callback(this[i], i, this) && res.push(this[i]);
	}
	return res;
};
 1
2
3
4
5
6
7
2
3
4
5
6
7
Array.prototype.MyFilter = function (callback) {
	const res = [];
	for (let i = 0; i < this.length; i++) {
		callback(this[i], i, this) && res.push(this[i]);
	}
	return res;
};