first
first<T>(array: T[]): T | undefinedSource: array.ts:415
Gets the first element of an array
Type Parameters
T— Array element type
Parameters
array(T[]) — The input array
Returns
T | undefined— First element or undefined
Example
CODE
first([1, 2, 3]) // 1
first([]) // undefined