• Split an array into two based on a condition.

    Returns

    A two dimensional array containing two arrays, where the first one includes all items where the given condition was met and the second one includes all items where it was not met.

    Type Parameters

    • T

    Parameters

    • arr: T[]

      Array to partition.

    • condition: ((item: T) => boolean)

      Function to determine to where to put each item.

        • (item: T): boolean
        • Parameters

          • item: T

          Returns boolean

    Returns [T[], T[]]

Copyright Ⓒ 2023 SAP SE or an SAP affiliate company. All rights reserved.