Bird
0
0

If a smart component passes a list of items to a dumb component via an input, and the dumb component modifies the list directly, what is the likely outcome?

medium📝 component behavior Q5 of 15
Angular - Advanced Patterns
If a smart component passes a list of items to a dumb component via an input, and the dumb component modifies the list directly, what is the likely outcome?
AThe dumb component's changes are ignored.
BThe smart component's data is unexpectedly changed.
CAngular throws a runtime error.
DThe dumb component creates a copy automatically.
Step-by-Step Solution
Solution:
  1. Step 1: Understand data flow in smart/dumb pattern

    Inputs are passed by reference for objects/arrays, so modifying them affects the original.
  2. Step 2: Analyze consequences of direct modification

    Modifying the list in dumb component changes the smart component's data unexpectedly.
  3. Final Answer:

    The smart component's data is unexpectedly changed. -> Option B
  4. Quick Check:

    Input objects are references, so changes affect parent [OK]
Quick Trick: Avoid mutating inputs; use copies instead [OK]
Common Mistakes:
  • Assuming inputs are immutable by default
  • Expecting Angular to clone inputs automatically
  • Ignoring reference behavior of objects

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes