Skip to content

Instantly share code, notes, and snippets.

@gasolin
Created May 12, 2014 02:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gasolin/c457f0ed377d0f19a644 to your computer and use it in GitHub Desktop.
Save gasolin/c457f0ed377d0f19a644 to your computer and use it in GitHub Desktop.
immediately-invoked func­tion expres­sions(IIFE) http://tech.myemma.com/iifes-javascript-control-variable-scope/
// Take con­trol of your globals
//basic
(function () {
// your code here
})();
// pass param in
(function ($) {
$(document).ready(function () {
// my code
});
})(jQuery);
// expose param out
var obj = (function () {
return {
methodA: ...
}
})();
obj.methodA();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment