Javatpoint Logo
Javatpoint Logo

RxJS findIndex() Conditional Operator

RxJS findIndex () operator is a conditional operator that emits only the Index of the first value emitted by the source observable that satisfies some specific condition.

We can say that the RxJS findIndex () operator returns the Index of the first value from the source observable, which meets some condition inside the predicate function. It is similar to the RxJS find() operator but emits the found value index instead of its value.

Syntax:

Following is the syntax of the RxJS findIndex(), conditional operator:

Or

Parameter Explanation

  • predicate_func: The predicate_function is used to decide the first Index to be picked when the condition satisfies
  • predicate: It specifies a function that is called with each item when the condition is satisfied.
  • thisArg: This is an optional argument used to determine the value in the predicate function. Its default value is undefined.

Return value

The RxJS find Index () operator returns an observable with the first value from the source observable, which meets the certain condition inside the predicate function.

Let us see an example of the RxJS find Index () operator to understand it clearly.

Example

Output:

After executing the above example, you will see the following result:

RxJS findindex() Conditional Operator

In the above example, you can see that it has emitted the index of the found value from the list, instead of the value itself. It has emitted the index 1means the second values because index is counted from 0. s


Next TopicRxJS Operators




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA