apiref
bsearch@1.0.0

lastIndex()  Function

Returns the last index in array whose value satisfies the predicate.

Signature

export declare function lastIndex<T>(array: readonly T[], predicate: (value: T, index: number, array: readonly T[]) => boolean): number;

Parameters

ParameterTypeDescription
arrayreadonly T[]

The array to search.

predicate(value: T, index: number, array: readonly T[]) => boolean

A predicate. There should exist some index I such that predicate(array[i]) returns true for all i <= I and returns false otherwise.

(Returns)number

The last index in array whose value satisfies the predicate, or -1 if no such index exists.