Skip to main content
Go to Latest
function findLast
import { findLast } from "https://deno.land/std@0.102.0/collections/find_last.ts";

Returns the last element in the given array matching the given predicate

Example:

const numbers = [ 4, 2, 7 ]
const lastEvenNumber = findLast(numbers, it => it % 2 === 0)

console.assert(lastEvenNumber === 2)

Parameters

array: Array<T>
predicate: Predicate<T>

Returns

T | undefined