head
Import from @varavel/vdl-plugin-sdk/utils/arrays.
Utility functions re-exported from es-toolkit (MIT License).
See https://github.com/toss/es-toolkit for more details.
Call Signature
Returns the first element of an array.
This function takes an array and returns the first element of the array.
If the array is empty, the function returns undefined.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of elements in the array. |
Parameters
| Parameter | Type | Description |
|---|---|---|
arr |
readonly [T, T] |
A non-empty array from which to get the first element. |
Returns
T
The first element of the array.
Example
Call Signature
Returns the first element of an array or undefined if the array is empty.
This function takes an array and returns the first element of the array.
If the array is empty, the function returns undefined.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of elements in the array. |
Parameters
| Parameter | Type | Description |
|---|---|---|
arr |
readonly T[] |
The array from which to get the first element. |
Returns
T | undefined
The first element of the array, or undefined if the array is empty.