Uloží stav objektu tak, aby sa doň dal neskôr vrátiť.
class Snapshot { constructor(text) { this.text = text; }} class Editor { #text = ''; write(text) { this.#text = text; } save() { return new Snapshot(this.#text); } restore(snapshot) { this.#text = snapshot.text; }} class History { #snapshots = []; // It keeps the snapshot, but never looks inside it. backup(editor) { this.#snapshots.push(editor.save()); } undo(editor) { editor.restore(this.#snapshots.pop()); }} history.backup(editor);editor.write('new text');history.undo(editor); // the editor is back in its original state