Bird
0
0

Given this Angular pipe usage:

medium📝 component behavior Q13 of 15
Angular - Pipes
Given this Angular pipe usage:
items = [1, 2, 3];
// Template: {{ items | customPipe }}

If customPipe is pure and the array items is mutated by items.push(4) without changing the reference, what will happen?
AThe pipe will run and update the output to include 4.
BAngular throws an error due to mutation.
CThe pipe runs only if change detection is manually triggered.
DThe pipe will not run; output remains unchanged.
Step-by-Step Solution
Solution:
  1. Step 1: Understand pure pipe input change detection

    Pure pipes run only when the input reference changes, not when the content inside the object changes.
  2. Step 2: Analyze mutation effect on pipe execution

    Mutating the array with push() does not change the reference, so the pure pipe does not run again and output stays the same.
  3. Final Answer:

    The pipe will not run; output remains unchanged. -> Option D
  4. Quick Check:

    Pure pipe ignores internal mutations = C [OK]
Quick Trick: Pure pipes need new object references to update [OK]
Common Mistakes:
  • Assuming mutation triggers pure pipe
  • Thinking Angular throws error on mutation
  • Believing manual change detection is required here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes