Created
June 8, 2014 15:34
-
-
Save lmartins/5091b6a68d45a38d8e5a to your computer and use it in GitHub Desktop.
Revealing Module Pattern with module extensions
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
| // 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 | |
| }; | |
| })(); |
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
| 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