当前位置: 代码迷 >> JavaScript >> js操作Array数组剔除元素等操作
  详细解决方案

js操作Array数组剔除元素等操作

热度:284   发布时间:2013-02-24 17:58:56.0
js操作Array数组删除元素等操作
Array.prototype.clear=function(){ 
this.length=0; 
} 
Array.prototype.insertAt=function(index,obj){ 
this.splice(index,0,obj); 
} 
Array.prototype.removeAt=function(index){ 
this.splice(index,1); 
} 
Array.prototype.remove=function(obj){ 
var index=this.indexOf(obj); 
if (index>=0){ 
this.removeAt(index); 
} 
} 

?

  相关解决方案