Toolbox-XToolbox-X

Get Last Array Element

Gets the last element of an array.

getLastArrayElement

Gets the last element of an array.

Function Signature

function getLastArrayElement<T>(array: T[]): T | undefined

Parameters

  • array (T[]): The array to get the last element from.

Returns

  • T | undefined: The last element of the array, or undefined if the array is empty.

Example

playground.ts

Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)

On this page