数组去重复

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());

每个程序员,都是艺术家.
原文地址:https://www.cnblogs.com/moriah/p/6502193.html