Skip to content

Instantly share code, notes, and snippets.

@roman01la
Created October 26, 2013 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roman01la/7165517 to your computer and use it in GitHub Desktop.
Save roman01la/7165517 to your computer and use it in GitHub Desktop.
JS Singleton
var Singletone = (function () {
var instance;
return function Construct_singletone () {
if (instance) {
return instance;
}
if (this && this.constructor === Construct_singletone) {
instance = this;
} else {
return new Construct_singletone();
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment