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