Function uniqWith

  • This method is like uniq except that it accepts comparator which is invoked to compare elements of array. The order of result values is determined by the order they occur in the array. The comparator is invoked with two arguments: (arrVal, othVal).

    Type Parameters

    • T
    • S

    Parameters

    • array: T[]

      The array to inspect.

    • Optionalcomparator: ((value: S) => any)

      The comparator invoked per element.

        • (value): any
        • Parameters

          • value: S

          Returns any

    Returns T[]

    Returns the new duplicate free array.

    4.0.0

    uniq, uniqBy

    const objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]

    uniqWith(objects, isEqual)
    // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]