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[]) { //implementation} Copy
function doSomething(array: T[])function doSomething(...varArgs: T[])function doSomething(first: undefined | T | T[], ...rest: T[]) { //implementation}
This wrapper methods makes it easy build an array from the input.
Either an array, the first element of the var args or undefined, if no argument was given.
undefined
Second to last element, if var args were used, empty array, if the first argument is an array.
Array from the input or empty array if no input was given.
Copyright Ⓒ 2024 SAP SE or an SAP affiliate company. All rights reserved.
We want to provide methods which accept a variable single number of elements and arrays. The overloaded signature to achieve this is:
This wrapper methods makes it easy build an array from the input.