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

# \_.flatten（减少一层嵌套）

## \_.flatten

**语法：**

```javascript
_.flatten(array)
```

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

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

**描述：**

减少一层`array`嵌套深度。

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

**参数：**

* `array (Array)`: 需要减少嵌套层级的数组。

**返回值：**

* `array (Array)`: 返回减少嵌套层级后的新数组。

**例子：**

```javascript
_.flatten([1, [2, [3, [4]], 5]]);
// => [1, 2, [3, [4]], 5]
```

> 数组中元素挨个进行减少一层嵌套深度
