O'Reilly logo

Mastering Reactive JavaScript by Erich de Souza Oliveira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The filter() operator

The filter() operator lets you create a new Observable after omitting some of the data from the original Observable. It receives a function as argument that is called for each element in the original Observable, and it must return an either true or false (actually it can be any truthy or falsy value). If the result of the execution of filterFunction for an object is true, then this object will be propagated; otherwise, it will be omitted.

The filter() operator has the following signature:

observable.filter(filterFunction,[thisContext]); 

The first parameter is mandatory and the second is optional:

  • filterFunction: This is a function that takes an element of the observable as input and returns any truthy or falsy value. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required