Last

Returns the last element of an array.

CategoryArrays
AuthorPol Gubau
Since1.0.0
Last Updated2025-03-15
TypeSync
CompatibilityUniversal

Example

  • Input

    last([1, 2, 3])

    Output:

    3

Return

The last element of the array or `undefined` if the array is empty.

Type: T | undefined

Props

NameTypeDefaultRequiredDescription
arrT[]nullYesThe array to get the last element from.

Notes

Returns `undefined` if the array is empty.

Tags

  • array
  • last
  • element

Related