findLastIndex
The findLastIndex() method returns the index of the last element of an array that satisfies a given condition.
Interactive example
Syntax
Classic signature
typescript
function findLastIndex<
GenericInput extends readonly unknown[]
>(
input: GenericInput,
predicate: (
element: GenericInput[number],
params: ArrayFindLastIndexParams
) => boolean
): number | undefinedCurried signature
typescript
function findLastIndex<
GenericInput extends readonly unknown[]
>(
predicate: (
element: GenericInput[number],
params: ArrayFindLastIndexParams
) => boolean
): (input: GenericInput) => number | undefinedHelper parameters
typescript
interface ArrayFindLastIndexParams {
index: number;
}Parameters
input: The array to search in.predicate: Predicate function that tests each element. Receives the element and an object containing the index.params.index: Position of the current element in the array.
Return value
The index of the last element that satisfies the condition, or undefined if no element matches.
