lmartins
6/8/2014 - 3:34 PM

Revealing Module Pattern with module extensions

Revealing Module Pattern with module extensions

var ModuleTwo = (function (Module) {
    
    Module.extension = function () {
        // another method!
    };
    
    return Module;
    
})(Module || {});
// 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
  };

})();