Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fonction/common/last.ts>last

A modern practical functional library
Latest
variable last
import { last } from "https://deno.land/x/fonction@v2.1.0-beta.4/common/last.ts";

Returns the last element of the given list or string.

Examples

Example 1

// String
last('') // ''
last('hello') // 'o'

Example 2

// Array
last('hello', 'new', 'world') // 'world'
last([]) // undefined
last(['one', 2, 3, 4]) // 4

type

<T extends string | readonly unknown[]>(val: T) => Last<T>