> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/array/xorwith.md).

# \_.xorWith（数组取差集）

**语法：**

```javascript
_.xorWith([arrays], [comparator])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L8615)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.xorwith)

**描述：**

该方法是像[`_.xor`](https://lodash.com/docs/4.17.10#xor)，除了它接受一个`comparator`，以调用比较数组的元素。 comparator 调用2个参数：*(arrVal, othVal)*.

**开始版本：**&#x34;.0.0

**参数：**

* `[arrays] (...Array)`: 要检查的数组。
* `[comparator] (Function)`: 调用每一个元素的比较函数。

**返回值：**

* `(Array)`: 返回过滤值后的新数组。

**例子：**

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

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