Array.prototype.push = function(){
console.log(“失效了”);
}
var arr = [];
arr.push(4);
console.log(arr);
Array.prototype.remove = function(val){
var index = this.indexOf(val);
this.splice(index,1);
return this;
}
var arr = [5,6,7];
console.log(arr.remove(6))
//sum
Array.prototype.sum = function(){
var s = 0;
for(var i = 0;i<this.length;i++){
s+=this[i];
}
return s;
}
var test = [1,2,3];
console.log(test.sum())