Javatpoint Logo
Javatpoint Logo

RxJS Max() Mathematical Operator

The RxJS max() operator is a mathematical operator that takes in an observable with all values and returns an observable with the maximum value. It takes in a compare function as an argument, which is optional.

Syntax:

Following is the syntax of the max() operator:

Parameter Explanation

comparer_func: It is used to filter the values to consider only the source observable's max value. It is optional. If it is not provided, the count() operator will consider the default function.

Return value

The return value of the max() operator is observable that provide the max value.

Let us see some examples of max() operator to understand it clearly.

Example 1

Output:

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

RxJS Max() Mathematical Operator

Example 2

Example of the max() operator with comparer functions:

Output:

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

RxJS Max() Mathematical Operator

Here we have used arrays and the values inside the array are compared using the function given in max() operator. After that the max value from the array is returned as output.


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