• We want to provide methods which accept a variable single number of elements and arrays. The overloaded signature to achieve this is:

    function doSomething(array: T[])
    function doSomething(...varArgs: T[])
    function doSomething(first: undefined | T | T[], ...rest: T[]) {

    This wrapper methods makes it easy build an array from the input.

    Type Parameters

    • T


    • firstOrArray: undefined | T | T[]

      Either an array, the first element of the var args or undefined, if no argument was given.

    • rest: T[]

      Second to last element, if var args were used, empty array, if the first argument is an array.

    Returns T[]

    Array from the input or empty array if no input was given.

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