数组去重复

var arr=[112,112,56,'hello',112,112,56,'hello','str1','str']

Arrary.prototype.chongfu=function(){

var res=[];

var json={};

for(var i=0;i<this.lengh;i++){

if(!json[this[i]]){

res.push(this[i]);

json[this[i]]=1; 

}

}

return res;

}

alert(arr.chongfu());

posted @ 2017-03-04 18:34  十二***  阅读(172)  评论(0编辑  收藏  举报