Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created November 5, 2009 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save subtleGradient/227165 to your computer and use it in GitHub Desktop.
Save subtleGradient/227165 to your computer and use it in GitHub Desktop.
// Basic closure, assumes window === this
(function(){
// require stuff here
})();
// Custom closure, this === anything you want
(function(){
// require stuff here
}).apply(this.global || this);
// Custom closure fn, no call. Load the code in one context and then execute it in another
function Moo(){
// require stuff here
};
Moo.apply(this);
Moo.apply(context1);
Moo.apply(context2);
Moo.apply(context3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment