BACK
ReferencefindIndex
Reference · 66

findIndex

findIndex

rxjs.dev

Returns the index of the first value that passes the predicate.

Signature

findIndex(predicate: (value: T, index: number, source: Observable) => boolean): OperatorFunction

What it does

Works like find, but emits the index of the found value. If there's no match, it emits -1 after the source completes.

When to use

Determining the position of the first matching event, or finding an element's index in a finite Observable list.

See also

find, elementAt

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...