last

array

Gets the last element of array.

Signature

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

Parameters

NameTypeDescription
arrayT[]The array to query

Returns

T | undefined - Returns the last element of array

Examples

Basic usage

import { last } from 'dashlite'

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

Output:

3

Available since version 1.0.0