1.数组扩展方法
1.1删除数组中的指定下标的元素
Array.prototype.remove = function(dx)
{
if(isNaN(dx)||dx>this.length){return false;}
this.splice(dx,1);
}
1.2删除数组重复项
如下实现方式在效率和实现方法及写法来说,是比较优的
Array.prototype.distinct = function(){
var self = this;
var _a = this.concat().sort();
_a.sort(function(a,b){
if(a == b){
var n = self.indexOf(a);
self.splice(n,1);
}
});
return self;
};
1.2参考链接:http://sfgeeq1987.iteye.com/blog/1260373