Skip to content

Instantly share code, notes, and snippets.

@davidlonjon
Created September 11, 2013 06:23
Show Gist options
  • Save davidlonjon/6519943 to your computer and use it in GitHub Desktop.
Save davidlonjon/6519943 to your computer and use it in GitHub Desktop.
JavaScript: Module Pattern
var MODULE = (function (ns, undefined) {
ns.publicVariable = 'My module public variable';
privateVariable = 'My module private variable';
ns.publicMethod = function () {
console.log(privateVariable);
};
privateMethod = function () {
privateVariable = "Change to my private variable";
};
return ns;
}(MODULE || {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment