> 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/uniqby.md).

# \_.uniqBy（数组去重）

**语法：**

```javascript
_.uniqBy(array, [iteratee=_.identity])
```

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

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

**描述：**

这个方法类似[`_.uniq`](https://lodash.com/docs/4.17.10#uniq)，除了它接受一个`iteratee`（迭代函数），调用每一个数组（`array`）的每个元素以产生唯一性计算的标准。iteratee 调用时会传入一个参数：*(value)*。

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

**参数：**

* `array (Array)`: 要检查的数组。
* `[iteratee=_.identity] (Array|Function|Object|string)`: 迭代函数，调用每个元素。&#x20;

**返回值：**

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

**例子：**

```javascript
_.uniqBy([2.1, 1.2, 2.3], Math.floor);
// => [2.1, 1.2]

// The `_.property` iteratee shorthand.
_.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }, { 'x': 2 }]
```
