first

array

Gets the first element of array. Alias for head.

Signature

first<T>(array: T[]): T | undefined

Parameters

NameTypeDescription
arrayT[]The array to query

Returns

T | undefined - Returns the first element of array

Examples

Basic usage

import { first } from 'dashlite'

const result = first([1, 2, 3])
console.log(result)

Output:

1

Available since version 1.0.0