JS中数组去除重复的方法
function unique(arr) {
var result = [], hash = [];
for (var i = 0, elem; (elem = arr[i]) != null; i++) {
if (!hash[elem]) {
result.push(elem);
hash[elem] = true;
}
}
return result;
}
var arr=[3,3,5,"f","f","d"];
unique(arr);//[3, 5, "f", "d"]
-----------------------------------------------------------------------小二给我来二两轮子!