typescript 从数组中删除dublicates

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript 从数组中删除dublicates相关的知识,希望对你有一定的参考价值。

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  name: 'uniqArray'
})
export class UniqArrayPipe implements PipeTransform {
  // remove duplicates from array
  transform(array?: any): any {
    return array.filter((thing, index) => {
      return index === array.findIndex(obj => {
        return JSON.stringify(obj) === JSON.stringify(thing);
      });
    });
  }
}

以上是关于typescript 从数组中删除dublicates的主要内容,如果未能解决你的问题,请参考以下文章