Bird
0
0

What is the likely performance impact of using trackBy in an *ngFor directive?

medium📝 Predict Output Q5 of 15
Angular - Performance Optimization
What is the likely performance impact of using trackBy in an *ngFor directive?
AImproves performance by reducing DOM manipulations
BSlows down rendering by adding extra checks
CHas no effect on performance
DCauses Angular to reload the entire list every time
Step-by-Step Solution
Solution:
  1. Step 1: Understand trackBy purpose

    trackBy helps Angular identify items uniquely to avoid unnecessary DOM updates.
  2. Step 2: Connect trackBy with performance

    By reducing DOM changes, trackBy improves rendering speed and efficiency.
  3. Final Answer:

    Improves performance by reducing DOM manipulations -> Option A
  4. Quick Check:

    trackBy reduces DOM updates = better performance [OK]
Quick Trick: Use trackBy to optimize *ngFor rendering [OK]
Common Mistakes:
  • Believing trackBy slows rendering
  • Thinking trackBy reloads entire list
  • Assuming trackBy has no effect

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes