Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
Created March 26, 2013 13:38
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 vishaltelangre/5245425 to your computer and use it in GitHub Desktop.
Save vishaltelangre/5245425 to your computer and use it in GitHub Desktop.
Module Design Pattern in JS
var module = {};
(function(exports){
exports.notGlobalFunction = function() {
console.log('I am not global');
};
}(module));
function notGlobalFunction() {
console.log('I am global');
}
notGlobalFunction(); //outputs "I am global"
module.notGlobalFunction(); //outputs "I am not global"
// REFERENCE: http://www.jblotus.com/2013/01/13/common-javascript-gotchas/#highlighter_342633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment