数组属性去重

时间:2021-09-06 07:42:53   收藏:0   阅读:33
  //去重复
    unique(arr1) {
      const res = new Map();
      return arr1.filter((a) => !res.has(a.level) && res.set(a.level, 1))
    },
    uniqueFun(arr, type) {
      const res = new Map();
      return arr.filter((a) => !res.has(a[type]) && res.set(a[type], 1));
    }

原文:https://www.cnblogs.com/linhan8888/p/15226306.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!