Home » RxJS skip() Filtering Operator

RxJS skip() Filtering Operator

by Online Tutorials Library

RxJS skip() Filtering Operator

RxJS skip() operator is a filtering operator used to return an observable that skips the first count items emitted by the source observable.

In other words, we can say that the RxJS skip() operator allows us to ignore the first x emissions from the source. It is generally used when we have an observable that always emits certain subscription values that we want to ignore. We should approach the RxJS skip() operator if we are only concerned about later emissions.

Syntax:

Following is the syntax of the RxJS skip() operator:

Or

Parameter Explanation

  • count: The count argument is used to specify the number of times the items will be skipped from the source observable.

Return value

The RxJS skip() operator’s return value is an observable that skips values emitted by the source Observable.

Let us see some examples of the RxJS skip() operator to understand it clearly.

Example 1 (Skipping values before emission)

Output:

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

RxJS skip() Filtering Operator

In the above example, you can see that it has skipped the first 5 emitted values. i.e.: 0, 1, 2, 3, and 4. It has emitted values after that skipped values.

Example 2 (Short hand for a specific filter use case)

Output:

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

RxJS skip() Filtering Operator

In the above example, you can see that the second method also gives the same result.


Next TopicRxJS Operators

You may also like