Skip to main content

findLast()

findLast<T>(predicate): (arr) => undefined | null | T

Returns the last element of the given array that satisfies the predicate. Returns null otherwise.

Type Parameters

T

The type of array elements.

Parameters

predicate

Predicate<T>

A predicate function to apply to each element of the array.

Returns

Function

Parameters

arr

T[]

Returns

undefined | null | T

Remarks

pure function

Example

import { findLast } from '@accelint/core';

findLast(x => !(x & 1))([1, 2, 3, 4, 5]);
// 4