Skip to main content

flatMapDepth

_.flatMapDepth(iteratee, depth, collection) # Ⓢ [Ⓣ][1] Ⓝ

This method is like _.flatMap except that it recursively flattens the



mapped results up to depth times.

Since​

4.7.0

Arguments​

  1. iteratee (Function): The function invoked per iteration.
  2. depth (number): The maximum recursion depth.
  3. collection (Array|Object): The collection to iterate over.

Returns​

(Array): Returns the new flattened array.

Example​

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

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