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 | undefinedParameters
array(T[]): The array to get the last element from.
Returns
T | undefined: The last element of the array, orundefinedif the array is empty.
Example
playground.ts
Last updated: Sun, Jun 14, 2026 07:06:16AM (UTC)
