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

x/prelude_js/last.ts>last

A standard module for functional programming
Latest
function last
import { last } from "https://deno.land/x/prelude_js@1.2.0/last.ts";

Returns the last element of the given string.

Examples

Example 1

import { last } from "https://deno.land/x/prelude_js@$VERSION/last.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(last(""), "");
assertEquals(last("abc"), "c");

Type Parameters

T extends string

Parameters

input: T

Any string.

Returns the last element of the given tuple.

Examples

Example 1

import { last } from "https://deno.land/x/prelude_js@$VERSION/last.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(last([]), undefined);
assertEquals(last([1, 2, 3]), 3);

Parameters

input: readonly [...unknown[], T]

Any tuple.

Returns the last element of the given iterable.

Examples

Example 1

import { last } from "https://deno.land/x/prelude_js@$VERSION/last.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts";

assertEquals(last(new Set(["x", "y", "z"])), "z");

Parameters

input: Iterable<T>

Any iterable.

Returns

T | undefined