Recall & Review
beginner
What is a pure pipe in Angular?
A pure pipe is a pipe that Angular executes only when it detects a pure change to the input value. Pure changes include changes to primitive types or object references. Pure pipes improve performance by avoiding unnecessary recalculations.
Click to reveal answer
beginner
What is an impure pipe in Angular?
An impure pipe is a pipe that Angular executes on every change detection cycle, regardless of whether the input value changed. This is useful when the pipe depends on mutable objects or external state.
Click to reveal answer
intermediate
How do you declare a pipe as impure in Angular?
You declare a pipe as impure by setting the 'pure' property to false in the @Pipe decorator, like this: @Pipe({name: 'myPipe', pure: false}).
Click to reveal answer
intermediate
Why should you avoid using impure pipes when possible?
Impure pipes run on every change detection cycle, which can hurt performance. Using pure pipes when possible helps Angular skip unnecessary work and keeps apps fast.
Click to reveal answer
advanced
Give an example scenario where an impure pipe is necessary.
When a pipe transforms data from a mutable object like an array that changes internally (e.g., items added or removed without changing the array reference), an impure pipe ensures the view updates correctly.
Click to reveal answer
When does Angular execute a pure pipe?
✗ Incorrect
Pure pipes run only when Angular detects a pure change to the input, such as a new object reference or a changed primitive value.
How do you mark a pipe as impure in Angular?
✗ Incorrect
You mark a pipe as impure by setting pure: false in the @Pipe decorator.
What is a downside of using impure pipes?
✗ Incorrect
Impure pipes run every change detection cycle, which can slow down the app if overused.
Which pipe type is best for transforming immutable data?
✗ Incorrect
Pure pipes are ideal for immutable data because they only run when the input changes.
If you have an array that changes internally but keeps the same reference, which pipe should you use?
✗ Incorrect
Impure pipes detect internal changes in mutable objects even if the reference stays the same.
Explain the difference between pure and impure pipes in Angular and when to use each.
Think about how Angular detects changes and when it runs pipes.
You got /4 concepts.
Describe how to declare an impure pipe and why you might need one.
Focus on the decorator setting and use case.
You got /4 concepts.