The Prototype Pattern
The GoF refers to the Prototype pattern as one that creates objects based on a template of an existing object through cloning.
We can think of the Prototype pattern as being based on prototypal
inheritance in which we create objects that act as prototypes for other
objects. The prototype object itself is effectively
used as a blueprint for each object the constructor creates. If the
prototype of the constructor function used contains a property called
name for example (as per the code
sample that follows), then each object created by that same constructor
will also have this same property (Figure 9-6).

Figure 9-6. Prototype pattern
Reviewing the definitions for this pattern in existing (non-JavaScript) literature, we may find references to classes once again. The reality is that prototypal inheritance avoids using classes altogether. There isn’t a “definition” object nor a core object in theory; we’re simply creating copies of existing functional objects.
One of the benefits of using the Prototype pattern is that we’re working with the prototypal strengths JavaScript has to offer natively rather than attempting to imitate features of other languages. With other design patterns, this isn’t always the case.
Not only is the pattern an easy way to implement inheritance, but it can come with a performance boost as well: when defining functions in an object, they’re all ...