Function flatMapDeep

  • This method is like flatMap except that it recursively flattens the mapped results.

    Type Parameters

    • T
    • TResult

    Parameters

    • array: T[]
    • iteratee: ListIterator<T, TResult | NestedArray<TResult>>

      The function invoked per iteration.

    Returns TResult[]

    Returns the new flattened array.

    4.7.0

    flatMap, flatMapDepth, flatten, flattenDeep, flattenDepth, map, mapKeys, mapValues

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

    flatMapDeep([1, 2], duplicate)
    // => [1, 1, 2, 2]