Design Patterns · Junior · Question 17 of 75
What is the Command pattern used for?
- ✓Correct answer: To represent an action as an object - for queues, logs and undo
- 2To unite developers into a cross-functional feature team
- 3To run JavaScript code from the terminal command line
Explanation
A command contains everything needed to perform an action and, if necessary, to undo it (execute/undo). This is how undo/redo in editors, operation queues and macros are implemented. Redux actions are a related idea: an action is described by an object.