let arr=[
{id:1,name:'AAAA'},
{id:2,name:'BBBB'}
]
let arr1=[
{id:1,name:'AAAA'},
{id:3,name:'CCCC'}
]
let arrs=[...arr,...arr1];
//根据id去重
let map=new Map();
for(let item of arrs){
if(!map.has(item.id)){
map.set(item.id,item)
}
}
let newArr=[...map.values()];//把map中所有的值取出来放进数组
05-14
158
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-23
125
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)