Zabalí volanie do objektu, ktorý sa dá odložiť, zaradiť do frontu alebo vrátiť.
class Command { execute() { throw new Error('abstraktná metóda'); } undo() { throw new Error('abstraktná metóda'); }} class InsertText extends Command { constructor(doc, text) { super(); this.doc = doc; this.text = text; } execute() { this.doc.insert(this.text); } undo() { this.doc.delete(this.text.length); }} class Button { history = []; press(command) { command.execute(); this.history.push(command); } undo() { const last = this.history.pop(); last.undo(); }} const button = new Button();button.press(new InsertText(doc, 'hello'));button.press(new InsertText(doc, ' world'));button.undo(); // a call can be undone, because it is an object