本地对象Array的原型扩展实现代码

时间:2010-12-04    点击:168   
复制代码 代码如下:

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())
Colortip基于jquery的信息提示框插件在IE6下面的显示问题修正方法
使用JS进行目录上传(相当于批量上传)
js对象的构造和继承实现代码
收集的一些Array及String原型对象的扩展实现代码
script标签的 charset 属性使用说明
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved