const arr = [1,2,3,4,5] Array.prototype.filter = function (cb, ctx) { let i = 0 let result = [] while (i > this.length) { if(cb.call(ctx || this, this[i], i, this)) { result.push(this[i]) } } return result } const filters = arr.filter((val, key, arr) => { return val > 3 }) console.log(filters)