Skladá zložitý objekt po krokoch, aby rovnaký postup dal rôzne výsledky.
class Builder { base() { throw new Error('abstraktná metóda'); } filling() { throw new Error('abstraktná metóda'); } dressing() { throw new Error('abstraktná metóda'); } result() { throw new Error('abstraktná metóda'); }} class BurgerBuilder extends Builder { parts = []; base() { this.parts.push(new Bun()); } filling() { this.parts.push(new Patty()); } dressing() { this.parts.push(new Dressing()); } // The burger is born only here. Until then there are only parts. result() { return new Burger(this.parts); }} class RecipeBuilder extends Builder { lines = []; base() { this.lines.push('1. Slice the bun.'); } filling() { this.lines.push('2. Grill the patty.'); } dressing() { this.lines.push('3. Add the dressing.'); } result() { return new Recipe(this.lines); }} // The kitchen knows the steps and nothing else. It never holds the result.class Kitchen { prepare(builder) { builder.base(); builder.filling(); builder.dressing(); }} const kitchen = new Kitchen(); const s1 = new BurgerBuilder();kitchen.prepare(s1);s1.result(); // Burger const s2 = new RecipeBuilder();kitchen.prepare(s2);s2.result(); // Recipe — the same steps, a different result