Singleton demo illustrates the Singleton Pattern. Also incorporates some jQuery functionality.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
demo.html
jquery-1.4.1.min.js
singleton.js

README.md

The Singleton Pattern

http://en.wikipedia.org/wiki/Singleton_pattern

The singleton pattern is a design pattern that is used to restrict instantiation of a class to one object.

This implementation differs from Gavins in that the user never has to initialize it, and instead only needs to ask for it. All initialization occurs internally in the lazy-load fashion: the first time it is requested it is internally initialized - thereafter the original instance is always returned. See line 49 of singleton.js for the lazy-load bit.

To view the demo, download the code and navigate to demo.html in your browser.

To view the code, click on that singleton.js file in the file list.

The Original Implementation

Gavins original implementation is here: