Skip to content

Instantly share code, notes, and snippets.

@preslavrachev
Created February 4, 2011 17:01
Show Gist options
  • Save preslavrachev/811369 to your computer and use it in GitHub Desktop.
Save preslavrachev/811369 to your computer and use it in GitHub Desktop.
Self Executing Anonymous Function
(function() {
doSomething();
})()
// or ...
//NOTE: This is basically doing the same thing, but we can gain a tiny bit performance, because we directly
//pass the current window, and document instances to the function, instead of making it iterate
//through the scope
(function(window,document,undefined) {
doSomething();
})(this,document) // these are the arguments being passed to the function at the beginning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment