← Back to design patterns map
🧬
Design Pattern

Prototype

Clone an existing object and customize the copy.

creational

Visual Diagram

base object
-> clone()
-> override fields
-> new variant

When To Use

  • ->Cloning environment configs
  • ->Creating many similar objects cheaply
  • ->Duplicating test data fixtures
Used in: Object.create(), structuredClone(), config cloning
prototype.js

Live Editor

Loading...

Output

Run code to see output...