Array.prototype.filter = function(fn){
for(var i =0; i < this.length; i++){
if(!fn(this[i], i)){
this.splice(i--, 1);
}
}
return this;
}
var b = [1,2,3,4,5];
b.filter(function(v){
return v > 3;
});
console.log(b);
时间: 2024-11-05 10:34:19