Skip to content

Instantly share code, notes, and snippets.

@geastwood
Created October 4, 2013 21:55
Show Gist options
  • Save geastwood/6833472 to your computer and use it in GitHub Desktop.
Save geastwood/6833472 to your computer and use it in GitHub Desktop.
js singleton template
window.singleton = (function(){
var instance;
var init = function() {
return Math.random();
};
return {
getInstance: function() {
if (!instance) {
instance = init();
}
return instance;
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment