es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
34 lines (33 loc) • 1.1 kB
TypeScript
import { ListIterateeCustom } from "../_internal/ListIterateeCustom.js";
//#region src/compat/array/findLastIndex.d.ts
/**
* Finds the index of the last element in the array that satisfies the predicate.
*
* @template T
* @param array - The array to search through.
* @param [predicate] - The predicate function, partial object, property-value pair, or property name.
* @param [fromIndex] - The index to start searching from.
* @returns The index of the last matching element, or -1 if not found.
*
* @example
* const users = [
* { user: 'barney', active: true },
* { user: 'fred', active: false },
* { user: 'pebbles', active: false }
* ];
*
* findLastIndex(users, o => o.user === 'pebbles');
* // => 2
*
* findLastIndex(users, { user: 'barney', active: true });
* // => 0
*
* findLastIndex(users, ['active', false]);
* // => 2
*
* findLastIndex(users, 'active');
* // => 0
*/
declare function findLastIndex<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): number;
//#endregion
export { findLastIndex };