数组对象去重

92 阅读1分钟

数组对象去重:

const list = arr.reduce((acc: any, curr) => {
          const index = acc.findIndex(
            (item: any) => item.去重属性值 === curr.去重属性值
          );
          if (index < 0) {
            acc.push(curr);
          }
          return acc;
        }, [])

最后list里面就是去重后的结果