• This method is like _.union except that it accepts comparator which is invoked to compare elements of arrays. The comparator is invoked with two arguments: (arrVal, othVal).

    Type Parameters

    • T

    Parameters

    • Optionalarrays: null | List<T>

      The arrays to inspect.

    • Optionalcomparator: Comparator<T>

      The comparator invoked per element.

    Returns T[]

    Returns the new array of combined values.

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

    _.unionWith(objects, others, _.isEqual);
    // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
  • Type Parameters

    • T

    Parameters

    • arrays: undefined | null | List<T>
    • arrays2: undefined | null | List<T>
    • Optionalcomparator: Comparator<T>

    Returns T[]

    _.unionWith

  • Type Parameters

    • T

    Parameters

    • arrays: undefined | null | List<T>
    • arrays2: undefined | null | List<T>
    • arrays3: undefined | null | List<T>
    • Rest...comparator: (
          | undefined
          | null
          | List<T>
          | Comparator<T>)[]

    Returns T[]

    _.unionWith