Bird
0
0

Which of the following is the correct syntax to unsubscribe from a subscription stored in a variable named sub?

easy📝 Syntax Q3 of 15
Angular - RxJS and Observables Fundamentals
Which of the following is the correct syntax to unsubscribe from a subscription stored in a variable named sub?
Aunsubscribe(sub);
Bsub.stop();
Csub.unsubscribe();
Dsub.close();
Step-by-Step Solution
Solution:
  1. Step 1: Recall Subscription API

    Angular subscriptions have an unsubscribe() method to stop listening.
  2. Step 2: Match correct method call

    Calling sub.unsubscribe() properly stops the subscription.
  3. Final Answer:

    sub.unsubscribe(); -> Option C
  4. Quick Check:

    Correct unsubscribe syntax = B [OK]
Quick Trick: Call unsubscribe() on subscription variable to stop it [OK]
Common Mistakes:
MISTAKES
  • Using stop() or close() which don't exist
  • Calling unsubscribe as a function with subscription as argument
  • Forgetting parentheses after unsubscribe

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes