Vytvára nové objekty klonovaním existujúceho namiesto volania konštruktora.
class Prototype { clone() { throw new Error('abstraktná metóda'); }} class FormTemplate extends Prototype { constructor() { super(); this.fields = []; this.style = null; } clone() { const copy = new FormTemplate(); copy.fields = [...this.fields]; copy.style = this.style; return copy; }} // The setup is expensive and happens once.const template = new FormTemplate();template.fields = loadFields();template.style = loadStyle(); const a = template.clone();const b = template.clone(); a !== b; // two different objectsa.style === b.style; // with the same setup