Skip to content

findIndex

findIndex<T>(array, item, comparisonStrategy?): number

Defined in: packages/core/src/array/find-index.ts:21

Finds the index of an item in an array using a specified equality comparison strategy.

Note: “strict” comparison uses the built-in Array.prototype.indexOf method, which is faster than a custom comparison function. For other strategies, a linear search (O(n)) is performed. On a sorted array, consider using a binary search for better performance.

T

T[]

The array to search in.

T

The item to find.

EqualityComparisonStrategy<T, T> = FIND_INDEX_DEFAULT_COMPARISON_STRATEGY

The equality comparison strategy to use (default is “strict”).

number

The index of the item in the array, or -1 if not found.