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

# \_.flatMapDepth（创建同阶数组）

**语法：**

```javascript
_.flatMapDepth(collection, [iteratee=_.identity], [depth=1])
```

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

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

**描述：**

该方法类似[`_.flatMap`](https://lodash.com/docs/4.17.10#flatMap)，不同之处在于，[`_.flatMapDepth`](https://lodash.com/docs/4.17.10#flatMapDepth)会根据指定的`depth`（递归深度）继续扁平化递归映射结果。

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

**参数：**

* `collection (Array|Object)`: 一个用来迭代的集合。
* `[iteratee=_.identity] (Array|Function|Object|string)`: 每次迭代调用的函数。
* `[depth=1] (number)`: 最大递归深度。

**返回值：**

* `(Array)`: 返回新扁平化数组。

**例子：**

```javascript
function duplicate(n) {
  return [[[n, n]]];
}

_.flatMapDepth([1, 2], duplicate, 2);
// => [[1, 1], [2, 2]]
```
