test() { const arr = [ { name: '张三', age: 22 }, { name: '李四', age: 22 }, { name: '张三', age: 23 } ] const map = new Map() const qc = arr.filter(key => !map.has(key.name) && map.set(key.name, 1)) // 这里对name属性进行去重 console.log('qc') console.log(qc) }
test() { const arr = [ { name: '张三', age: 22 }, { name: '李四', age: 22 }, { name: '张三', age: 23 } ] const map = new Map() const qc = arr.filter(key => !map.has(key.name) && map.set(key.name, 1)) // 这里对name属性进行去重 console.log('qc') console.log(qc) }