Function intersectionWith

  • This method is like intersection except that it accepts comparator which is invoked to compare elements of arrays. The order and references of result values are determined by the first array. The comparator is invoked with two arguments: (arrVal, othVal).

    Type Parameters

    • T

    Parameters

    • Rest ...arrays: any[]

      The arrays to inspect.

      Rest

    Returns T[]

    Returns the new array of intersecting values.

    Since

    5.11.0

    Example

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

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