Skip to content

Instantly share code, notes, and snippets.

@shaunwallace
Created November 14, 2014 11:48
Show Gist options
  • Save shaunwallace/6ecbaf1e4167a6b538ae to your computer and use it in GitHub Desktop.
Save shaunwallace/6ecbaf1e4167a6b538ae to your computer and use it in GitHub Desktop.
Module Pattern Definition
var APP = (function() {
// private members
var foo = true;
var bar = false;
// private method
function baz() {
return 1;
}
// public api
return {
fooBar : function() {
return 0;
}
}
}());
APP.foo; // will output undefined
APP.baz(); // will throw an Uncaught TypeError
APP.fooBar; // will outout 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment