// 实现一个filter方法let x = [2, 3, 1, 3, 5]Array.prototype._filter = function (fn) {if (typeof fn !== "function") {throw new TypeError('Not Function')}let res = []for (let i of this) {if (fn(i)) res.push(i)}return res}console.log(x._filter(x => x > 2)); // 3,3,5
