Bird
0
0

Why does Angular's OnPush strategy rely on immutable data patterns for optimal performance?

hard📝 Conceptual Q10 of 15
Angular - Performance Optimization
Why does Angular's OnPush strategy rely on immutable data patterns for optimal performance?
ABecause OnPush disables all change detection except for immutable inputs
BBecause Angular cannot detect any changes without immutable data
CBecause OnPush detects changes by comparing input references, not deep object mutations
DBecause mutable data causes Angular to throw errors with OnPush
Step-by-Step Solution
Solution:
  1. Step 1: Understand OnPush detection mechanism

    OnPush checks input references to detect changes, ignoring deep mutations inside objects.
  2. Step 2: Connect to immutable data

    Immutable data ensures new references on changes, allowing OnPush to detect updates efficiently.
  3. Final Answer:

    Because OnPush detects changes by comparing input references, not deep object mutations -> Option C
  4. Quick Check:

    OnPush + immutable data = efficient reference checks [OK]
Quick Trick: OnPush compares references, so use immutable data [OK]
Common Mistakes:
  • Thinking Angular throws errors with mutable data
  • Believing OnPush disables all detection except immutable inputs
  • Assuming Angular detects deep mutations automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes