![]() |
VOOZH | about |
Lodash _.unionWith() method accepts a comparator which is invoked to compare elements of arrays. The order of result values is determined from the first array in which the value occurs. The comparator is invoked with two arguments: (arrVal, othVal).
_.unionWith(array, [comparator]);Example 1: In this example, we are getting the union of the given two arrays by the use of the lodash _.unionWith() method.
Output:
[{'a': 1, 'b': 2 }, { 'b': 2}]Example 2: In this example, we are getting the union of the given two arrays by the use of the lodash _.unionWith() method.
Output:
[{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]