本地对象Array的原型扩展
时间:2010-12-04 来源:焱悠

Array.prototype.del=function(){
var b={},c,i=0,l=this.length,j;
for(;i<l;i++){
c=this.shift();
c in b ? b[c]++ : b[c]=0;
}
for(j in b){
if(b[j]>0)this.push(+j||j);
}
return this;
}
var a=[1,2,2,3,3,3,'a','b','b'];
alert(a.del());

Array.prototype.del=function(){
return (function (i, n, j, u, o){
for (; i < j; i++) {
o = this[i];
o in u ? 0 : (u[this[n++] = o] = 1)
}
this.length = n;
return this
}).call(this, 0, 0, this.length, {})
}
var a=[1,2,2,3,3,3,'a','b','b'];
alert(a.del())
相关阅读 更多 +
- 系统休眠文件删除后果 如何删除计算机的休眠文件 2025-04-22
- 站群服务器是什么意思 站群服务器的作用 站群服务器和普通服务器的区别 2025-04-22
- jQuery插件有何作用 jQuery插件的使用方法 2025-04-22
- jQuery插件有哪些种类 简单的jQuery插件实例 2025-04-22
-