unique(arr) {
const person = [{ id: 0, name: '小明' }, { id: 1, name: '小张' }, { id: 2, name: '小李' }, { id: 3, name: '小孙' }, { id: 1, name: '小周' }, { id: 2, name: '小陈' }];
const obj = {};
// eslint-disable-next-line no-unused-vars
const peon = person.reduce((cur, next) => {
// eslint-disable-next-line no-unused-expressions
obj[next.id] ? '' : obj[next.id] = true && cur.push(next);
return cur;
}, []);// 设置cur默认类型为数组,并且初始值为空的数组 console.log(peon);;
console.log(peon);
},