Angular - Advanced PatternsHow can you prevent a dumb component from accidentally mutating an input array passed from a smart component?AUse @Output to send the array back to the smart component for modification.BMark the input property as readonly in the dumb component.CDisable change detection in the dumb component.DCreate a copy of the array inside the dumb component before modifying it.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand mutation risksInputs are references; modifying them directly changes parent data.Step 2: Choose safe modification methodCreating a copy inside dumb component avoids mutating the original array.Final Answer:Create a copy of the array inside the dumb component before modifying it. -> Option DQuick Check:Clone inputs before modifying to avoid side effects [OK]Quick Trick: Clone arrays before changing in dumb components [OK]Common Mistakes:Assuming readonly prevents mutation at runtimeExpecting dumb components to modify inputs directlyDisabling change detection to fix mutation issues
Master "Advanced Patterns" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Advanced Patterns - Why design patterns matter - Quiz 1easy Advanced Patterns - Facade service pattern - Quiz 1easy Advanced Patterns - Facade service pattern - Quiz 9hard Animations - Enter and leave animations - Quiz 8hard Internationalization and Accessibility - Accessibility testing basics - Quiz 13medium Internationalization and Accessibility - Why i18n matters - Quiz 14medium Performance Optimization - Web workers for heavy computation - Quiz 8hard Server-Side Rendering - TransferState for data sharing - Quiz 2easy State Management - NgRx store concept - Quiz 11easy Testing - Testing routing and navigation - Quiz 13medium