Bird
0
0

Given this code, what will be logged?

medium📝 component behavior Q13 of 15
Angular - RxJS Operators
Given this code, what will be logged?
import { of } from 'rxjs';
import { map } from 'rxjs/operators';

of(1, 2, 3).pipe(
  map(x => x + 1)
).subscribe(console.log);
A1 2 3
B2 3 4
C[2, 3, 4]
DError: map is not a function
Step-by-Step Solution
Solution:
  1. Step 1: Understand the source observable

    of(1, 2, 3) emits values 1, then 2, then 3 sequentially.
  2. Step 2: Apply the map transformation

    The map adds 1 to each value, so outputs are 2, 3, and 4.
  3. Final Answer:

    2 3 4 -> Option B
  4. Quick Check:

    Input + 1 = Output [OK]
Quick Trick: map changes each value, so 1 becomes 2, etc. [OK]
Common Mistakes:
MISTAKES
  • Expecting original values without change
  • Thinking output is an array instead of separate logs
  • Confusing import syntax causing runtime error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes