根据数组元素对象中name属性来为数组去重 functionarrRemoveRepet(oldarr) {letnewArr = [];constobj = {}; newArr = oldarr.reduce(function(prev, cur) { obj[cur.name] ?'': (obj[cur.name] =true&& prev.push(cur));returnprev; }, []);returnnewArr; }//返回结果为 [ {id:0001, name:'us...
oldarr=[ {id:0001, name:'user1'}, {id:0003, name:'user2'}, {id:0002, name:'user1'}, {id:0003, name:'user2'} ] 根据数组元素对象中name属性来为数组去重 function arrRemoveRepet(oldarr) { let newArr = []; const obj = {}; newArr = oldarr.reduce(function(prev, cur) { obj...