js数组去重
var list = [{id:1, name:'111'}, {id:2, name:'222'}, {id:2, name:'333'}];
function distinctListById(arr){
var tmp = {};
if(arr && arr.length){
for(var i = 0; i < arr.length; i++){
if(!tmp[arr[i].id]){
tmp[arr[i].id] = 1;
}else{
arr.splice(i, 1);
}
}
}
return arr;
}