Design Patterns · Junior · Question 23 of 75
What is a Memento for?
- ✓Correct answer: Saving an object's state so you can return to it later (undo)
- 2Taking a screenshot of the page for a bug tracker report
- 3Remembering a function call's result to speed up repeated calls
Explanation
A memento stores state without exposing the object's internals. Change history in an editor or the Redux DevTools "time machine" are examples. With immutable data, a memento is simply a reference to a previous version.