Skip to content

Instantly share code, notes, and snippets.

@bradleykronson
Created August 19, 2013 13:55
Show Gist options
  • Save bradleykronson/6269391 to your computer and use it in GitHub Desktop.
Save bradleykronson/6269391 to your computer and use it in GitHub Desktop.
Module Pattern The module pattern gives us the ability to create private and public methods. For example, in the code below, the variable _index and the method privateMethod are private. increment and getIndex are public.
var Module = (function() {
var _index = 0;
var privateMethod = function() {
return _index * 10;
}
return {
increment: function() {
_index += 1;
},
getIndex: function() {
return _index;
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment