Created
July 13, 2013 10:51
-
-
Save pbrewczynski/5990314 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/*Exports | |
This next variation allows us to declare globals without consuming them and could similarly support the concept of global imports seen in the last example.*/ | |
// Global module | |
var myModule = (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