• Flattens an array up to the specified depth

    Example

    flatten([1, [2], 3, 4]); // [1, 2, 3, 4]
    

    Example

    flatten([1, [2, [3, [4, 5], 6], 7], 8], 2); // [1, 2, 3, [4, 5], 6, 7, 8]
    

    Type Parameters

    • T

    Parameters

    • arr: T[]
    • Optional depth: number = 1

    Returns unknown[]

Generated using TypeDoc