返回顶部

jquery 对象数组根据某个属性过滤重复

arr:数组,type:根据那个属性来过滤

function unique(arr, type) {
const res = new Map();
return arr.filter((a) => !res.has(a[type]) && res.set(a[type], 1));
}

posted @ 2020-11-09 13:51  豪shr  阅读(308)  评论(0)    收藏  举报