js数组深度去重
数组对象深度去重
var arr = [
{id: 1, name: '周瑜1'},
{id: 3, name: '王昭君1'},
{id: 2, name: '李白1'},
{id: 1, name: '周瑜2'},
{id: 2, name: '李白1'},
{id: 3, name: '王昭君2'}
];
let newobj = {};
arr = arr.reduce((preVal, curVal) => {
newobj[curVal.name] ? ''
原创
2020-11-17 11:25:13 ·
307 阅读 ·
0 评论