codetrix - v1.5.0
    Preparing search index...

    Function flatten

    • Flattens a nested array into a single-level array.

      Type Parameters

      • T

        The type of array elements.

      Parameters

      • array: any[]

        The nested array to flatten.

      Returns T[]

      A new flattened array.

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