|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Rev | Line | |
|---|
| [a762898] | 1 | import { ListIterateeCustom } from '../_internal/ListIterateeCustom.js';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Finds the index of the last element in the array that satisfies the predicate.
|
|---|
| 5 | *
|
|---|
| 6 | * @template T
|
|---|
| 7 | * @param {ArrayLike<T> | null | undefined} array - The array to search through.
|
|---|
| 8 | * @param {ListIterateeCustom<T, boolean>} [predicate] - The predicate function, partial object, property-value pair, or property name.
|
|---|
| 9 | * @param {number} [fromIndex] - The index to start searching from.
|
|---|
| 10 | * @returns {number} The index of the last matching element, or -1 if not found.
|
|---|
| 11 | *
|
|---|
| 12 | * @example
|
|---|
| 13 | * const users = [
|
|---|
| 14 | * { user: 'barney', active: true },
|
|---|
| 15 | * { user: 'fred', active: false },
|
|---|
| 16 | * { user: 'pebbles', active: false }
|
|---|
| 17 | * ];
|
|---|
| 18 | *
|
|---|
| 19 | * findLastIndex(users, o => o.user === 'pebbles');
|
|---|
| 20 | * // => 2
|
|---|
| 21 | *
|
|---|
| 22 | * findLastIndex(users, { user: 'barney', active: true });
|
|---|
| 23 | * // => 0
|
|---|
| 24 | *
|
|---|
| 25 | * findLastIndex(users, ['active', false]);
|
|---|
| 26 | * // => 2
|
|---|
| 27 | *
|
|---|
| 28 | * findLastIndex(users, 'active');
|
|---|
| 29 | * // => 0
|
|---|
| 30 | */
|
|---|
| 31 | declare function findLastIndex<T>(array: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>, fromIndex?: number): number;
|
|---|
| 32 |
|
|---|
| 33 | export { findLastIndex };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.