var arr=[{id:'1',name:'张三'},{id:'1',name:'张三'},{id:'2',name:'李四'}];
得到:var arr=[{id:'1',name:'张三'},{id:'2',name:'李四'}];
varresult = [];
varobj = {};
for(vari = 0; i < arr.length; i++) {
if(!obj[arr[i].key]) {
result.push(arr[i]);
obj[arr[i].key] =true;
}
}
console.log(result);