Function compact

  • Creates a new array with all falsy and empty values removed.

    Example

    compact([0, 1, false, 2, '', 3])
    // [1, 2, 3]

    Returns

    A new array with the filtered values

    Type Parameters

    • T

    Parameters

    • arr: T[]

      The array to compact

    Returns T[]

  • Type Parameters

    • T

    Parameters

    • arr: T

    Returns Partial<T>

Generated using TypeDoc