Skip to content

Instantly share code, notes, and snippets.

@lmartins
Created June 8, 2014 15:34
Show Gist options
  • Select an option

  • Save lmartins/5091b6a68d45a38d8e5a to your computer and use it in GitHub Desktop.

Select an option

Save lmartins/5091b6a68d45a38d8e5a to your computer and use it in GitHub Desktop.
Revealing Module Pattern with module extensions
// http://toddmotto.com/mastering-the-module-pattern/
var Module = (function () {
var _privateMethod = function () {
// private
// by convention private methods are prefixed with an underscore to
// differentiate them
};
var someMethod = function () {
// public
};
var anotherMethod = function () {
// public
};
return {
someMethod: someMethod,
anotherMethod: anotherMethod
};
})();
var ModuleTwo = (function (Module) {
Module.extension = function () {
// another method!
};
return Module;
})(Module || {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment