Function uniq

  • Creates a duplicate-free version of an array, using a Set for equality comparisons, in which only the first occurrence of each element is kept. The order of result values is not guaranteed.

    Returns

    Returns the new duplicate free array.

    Example

    uniq([2, 1, 2])
    // [2, 1]

    uniq([2.1, 1.2, 2.3], Math.floor)
    // [2.1, 1.2]

    See

    sortedUniq

    Type Parameters

    • T

    Parameters

    • arr: Iterable<T>

      The array containing duplicated elements

    • Optional fn: Iteratee<T, any, any>

      The iteratee invoked per element.

    Returns T[]

  • Type Parameters

    • T

    Parameters

    • arr: Iterable<T>
    • Optional fn: PropertyKey

    Returns T[]

Generated using TypeDoc