firstArrayItem
Returns the first item in the array, collection or enumerable object.
Signature
firstArrayItem<T>(array: TList<T> | undefined, index: number, default?: T): T | undefined
Parameters
Name | Type | Optional | Description |
---|---|---|---|
array | TList<T> | No | Specifies the array, collection or enumerable object. |
default | T | Yes | Optional parameter which specifies the default value if there is no first item. |
Return value
Returns the first item or undefined
if there is none.
Example
import { firstArrayItem } from "@tripetto/runner";
firstArrayItem<number>([1, 2, 3]); // Returns `1`