Created
December 9, 2016 15:14
-
-
Save ajaegers/3f6840f0b5f2c3cac76fb82ae9a6d3c1 to your computer and use it in GitHub Desktop.
Javascript template / Basic module pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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