VOOZH about

URL: https://www.geeksforgeeks.org/javascript/lodash-_-xorwith-method/

⇱ Lodash _.xorWith() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Lodash _.xorWith() Method

Last Updated : 15 Jul, 2025

Lodash _.xorWith() method is similar to the _.xor() method except that it accepts a comparator which is invoked to compare elements of arrays. Order of result values which is determined by the order they occur in the arrays.

Syntax:

_.xorWith([arrays], [comparator]);

Parameters:

  • [arrays]: This parameter holds the arrays to inspect.
  • [comparator] (Function): This parameter holds the comparator invoked per element and is invoked with two arguments(arrVal, othVal).

Return Value:

  • This method is used to return the new array of filtered values.

Example 1: In this example, we are operating xor on the given arrays and printing the results in the console.

Output:

[{ x: 4, y: 3 }, { x: 3, y: 3 }]

Example 2: In this example, we are operating xor on the given arrays and printing the results in the console.

Output:

[ 23, 4, 6, 98 ]

Example 3: In this example, we are operating xor on the given arrays and printing the results in the console.

Output:

[ 's', 'r' ]

Note: This code will not work in normal JavaScript because it requires the library lodash to be installed.

Comment