Function xorWith

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

    Type Parameters

    • T

    Parameters

    • comparator: Function

      The comparator invoked per element.

    • Rest ...arrays: T[][]

      The arrays to inspect.

      Rest

    Returns T[]

    Returns the new array of filtered values.

    Since

    5.7.0

    See

    [[difference]], [[union]], [[unionBy]], [[unionWith]], [[without]], [[xor]], [[xorBy]]

    Example

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

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