日期:2014-05-16 浏览次数:20539 次
?
/**
* 删除数组指定下标或指定对象
* arr.remove(2);//删除下标为2的对象(从0开始计算)
* arr.remove(str);//删除指定对象
*/
Array.prototype.remove=function(obj){
for(var i =0;i <this.length;i++){
var temp = this[i];
if(!isNaN(obj)){
temp=i;
}
if(temp == obj){
for(var j = i;j <this.length;j++){
this[j]=this[j+1];
}
this.length = this.length-1;
}
}
}