Skip to content

Instantly share code, notes, and snippets.

@getify
Created May 12, 2010 15:56
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 getify/398757 to your computer and use it in GitHub Desktop.
Save getify/398757 to your computer and use it in GitHub Desktop.
var FOO = (function() {
var a = "Hello";
return {
something:function(){
alert(a); // referenced via closure
}
};
})();
FOO.something();
var FOO = new (function() {
this.a = "Hello";
this.something = function() {
alert(this.a); // referenced via "this"
};
})();
FOO.something();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment