Skip to content

Instantly share code, notes, and snippets.

@husa
Created July 24, 2013 20:35
Show Gist options
  • Save husa/6074290 to your computer and use it in GitHub Desktop.
Save husa/6074290 to your computer and use it in GitHub Desktop.
Singleton pattern with instance in a closure
function Singleton() {
var instance,
that = this || {};
Singleton = function() {
return instance;
}
Singleton.prototype = that;
instance = new Singleton();
instance.constructor = Singleton;
that.prop = 'some property'
return instance;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment