日期:2014-05-16  浏览次数:20482 次

js array替换索引位置的值

?Array.prototype.del=function(n){ //n表示第几项,从0开始算起。 ?//prototype为对象原型,注意这里为对象增加自定义方法的方法。 ?//如果n<0,则不进行任何操作。 ?

if(n<0)?

return this; ?

else ?

return this.slice(0,n).concat(this.slice(n+1,this.length));

};