let objArr = [{name: ‘xue‘,age: 24},{name: ‘xue‘,age: 25},{name:‘qing‘}]
const res = new Map();
objArr = objArr.filter((arr) => !res.has(arr.name) && res.set(arr.name, 1))
reduce方法
let obj = {}
let objArr = [{name: ‘xue‘,age: 24},{name: ‘xue‘,age: 25},{name:‘qing‘}]
objArr = objArr.reduce((prev, item) => {
if(!obj[item.name]){
prev.push(item)
obj[item.name] = true
}
return prev
}, [])