1. 用数组filter方法去重
var arr = [1,2,3,3,1,4];
var obj = {};
arr.filter(
function(item){
if(!obj[item]){
obj[item] = true;
return item;
}
}
);
// [1, 2, 3, 4]
var arr = [1,2,3,3,1,4];
var obj = {};
arr.filter(
function(item){
if(!obj[item]){
obj[item] = true;
return item;
}
}
);
// [1, 2, 3, 4]