Angular

RxJS Operators

map, filter, switchMap, mergeMap, concatMap, debounceTime, distinctUntilChanged, combineLatest, forkJoin, catchError

24 interview questionsยท
Mid-Level
1

What is the role of the map operator in RxJS?

Answer

The map operator transforms each value emitted by an observable by applying a projection function. It does not change the number of emissions or the stream structure, only the individual values. This operator is fundamental for data transformation, such as converting an HTTP response object into a specific array of elements.

2

What is the role of the filter operator in RxJS?

Answer

The filter operator only allows values that satisfy a condition defined by a predicate function to pass through. Values that do not match the predicate are simply ignored and not emitted to downstream observers. This operator is essential for reducing the data stream to only relevant elements.

3

How to transform an array of IDs into an array of user objects with map?

Answer

The map operator applies a transformation function to each emitted value. To transform an array of IDs into objects, simply use map with a function that creates the desired objects from the IDs. This approach is common for enriching raw data with additional properties or restructuring it according to application needs.

4

What is the difference between RxJS map and JavaScript Array map?

5

How to filter an observable to get only even numbers?

+21 interview questions

Master Angular for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free