> 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/uniqwithff08-shu-zu-qu-zhong-ff09.md).

# \_.uniqWith（数组去重）

**语法：**

```javascript
_.uniqWith(array, [comparator])
```

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

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

**描述：**

这个方法类似[`_.uniq`](https://lodash.com/docs/4.17.10#uniq)， 除了它接受一个`comparator`调用比较`arrays`数组的每一个元素。 comparator 调用时会传入2个参数：*(arrVal, othVal)*。

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

**参数：**

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

**返回值：**

* `(Array)`: 返回新的去重后的数组。

**例子：**

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

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