Carl Danley

The Singleton Pattern

This pattern restricts instantiation of an object to a single reference thus reducing its memory footprint and allowing a "delayed" initialization on an as-needed basis. This isn't too common amongst JavaScript projects today but more common in WordPress (see Eric Mann's in-depth article here).

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




Additional Resources

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