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) }
2024-04-12 16:21:26
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) }