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);
}
}
本文介绍了一种在JavaScript中扩展数组原型的方法,包括清空数组、在指定位置插入元素、删除指定位置的元素以及移除特定对象等实用功能。

被折叠的 条评论
为什么被折叠?



