# \_.uniq（数组去重）

**语法：**

```javascript
_.uniq(array)
```

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

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

**描述：**

创建一个去重后的`array`数组副本。使用了[`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)做等值比较。只有第一次出现的元素才会被保留。

**开始版本：**&#x30;.1.0

**参数：**

* `array (Array)`: 要检查的数组。

**返回值：**

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

**例子：**

```javascript
_.uniq([2, 1, 2]);
// => [2, 1]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://lodash.shujuwajue.com/array/uniq.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
