• Split an array into two based on a condition.

    Type Parameters

    • T

    Parameters

    • arr: T[]

      Array to partition.

    • condition: (item: T) => boolean

      Function to determine to where to put each item.

    Returns [T[], T[]]

    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.

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