The Prototype Pattern

The prototype pattern focuses on creating an object that can be used as a blueprint for other objects through prototypal inheritance. This pattern is inherently easy to work with in JavaScript because of the native support for prototypal inheritance in JS which means we don't need to spend time or effort imitating this topology.

This article is part of a series called JavaScript Design Patterns.

Advantages

  • New objects created from the "skeleton" of an existing object inherit references to existing functions on the prototype chain, thus boosting performance and keeping memory footprints to a minimum.
  • Great for an application where the focus is on object creation

Disadvantages

  • Overkill for a project that uses very few objects and/or does not have an underlying emphasis on the extension of prototype chains

Example

Additional Resources

http://www.uipress.com/patterns-in-javascript-the-prototype-pattern/#.Uh9GQmRgYWA
http://www.geraintwilliams.net/2013/03/javascript-design-patterns.html
http://addyosmani.com/resources/essentialjsdesignpatterns/book/#prototypepatternjavascript

Other Common JS Patterns

The Module Pattern
The Revealing Module Pattern
The Singleton Pattern
The Observer Pattern
The Mediator Pattern
The Prototype Pattern
The Facade Pattern
The Factory Pattern