Skip to main content
variable last
import { last } from "https://deno.land/x/30_seconds_of_typescript@v1.0.1/util.ts";

Returns the last element in an array.

Check if arr is truthy and has a length property, use arr.length - 1 to compute the index of the last element of the given array and return it, otherwise return undefined.

type

(arr?: any[]) => unknown