Library API
    Preparing search index...

    Function distinct

    • Returns an array with no repeated elements.

      Type Parameters

      • T

      Parameters

      • arr: T[]

        The array to extract distinct elements from

      Returns T[]

      A new array containing only distinct elements

      const unique = distinct([1, 1, 2, 3]);
      
    • Returns a mapped array with no repeated elements.

      Type Parameters

      • T
      • S

      Parameters

      • arr: T[]

        The array to extract distinct elements from

      • mapfn: (value: T, index: number, array: T[]) => S

        Optional mapping function to apply before checking for distinctness

      • OptionalthisArg: any

        Optional this context for the mapping function

      Returns S[]

      A new array containing only distinct elements

      const uniqueIds = distinct(users, user => user.id);