去除一个数组中的相同元素
let resdata=[{id:'1',name:'小花’},{id:'2',name:'小明’},{id:'3',name:'小马哥'},{id:'1',name:'小王'}]
let hash = {};
let newArr = resdata.reduce((item, next) => {
hash[next.benchmarkCode] ? '' : hash[next.benchmarkCode] = true && item.push(next);
return item
}, []);
console.log(newArr)

浙公网安备 33010602011771号