Skip to content

Instantly share code, notes, and snippets.

@ajaegers
Created December 9, 2016 15:14
Show Gist options
  • Save ajaegers/3f6840f0b5f2c3cac76fb82ae9a6d3c1 to your computer and use it in GitHub Desktop.
Save ajaegers/3f6840f0b5f2c3cac76fb82ae9a6d3c1 to your computer and use it in GitHub Desktop.
Javascript template / Basic module pattern
/**
* Global module
* @source https://addyosmani.com/resources/essentialjsdesignpatterns/book/
*/
var App = (function () {
// Module object
var module = {},
privateVariable = "Hello World";
function privateMethod() {
// ...
}
module.publicProperty = "Foobar";
module.publicMethod = function () {
console.log( privateVariable );
};
return module;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment