first
The first() method returns the first element of an array.
Interactive example
Syntax
typescript
function first<
GenericInput extends readonly unknown[]
>(
input: GenericInput
): GenericInput extends AnyTuple
? GenericInput[0]
: GenericInput[number] | undefinedParameters
input: The array from which to retrieve the first element.
Return value
The first element of the array, or undefined if the array is empty.
