head
arrayGets the first element of array.
Signature
head<T>(array: T[]): T | undefinedParameters
| Name | Type | Description |
|---|---|---|
array | T[] | The array to query |
Returns
T | undefined - Returns the first element of array
Examples
Basic usage
import { head } from 'dashlite'
const result = head([1, 2, 3])
console.log(result)Output:
1Empty array
import { head } from 'dashlite'
const result = head([])
console.log(result)Output:
undefinedAvailable since version 1.0.0