/**
* @description:2个对象数组去重复值,根据key
* @param {*}
* @return {*}
*/
const uniq = (arr1: any[], arr2: any[], key: string) => {
let ids = arr2.map((item) => item[key])
console.log(ids)
return arr1.filter((el) => {
return !ids.includes(el[key])
})
}
console.log(uniq(arr1, arr2, "id"));
typescript 2个对象数组去重
最新推荐文章于 2024-05-22 21:39:25 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)