Skip to content

Instantly share code, notes, and snippets.

@jaredwilli
Created December 6, 2010 21:05
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 jaredwilli/730945 to your computer and use it in GitHub Desktop.
Save jaredwilli/730945 to your computer and use it in GitHub Desktop.
Singleton
function MyScript(){}
(function() {
var THIS = this;
function defined(x) {
return typeof x != 'undefined';
}
this.ready = false;
this.init = function() {
this.ready = true;
};
this.doSomething = function() {};
var options = {
x : 123,
y : 'abc'
};
this.define = function(key, value) {
if(defined(options[key])) {
options[key] = value;
}
};
}).apply(MyScript);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment