Last active
February 13, 2017 13:57
-
-
Save danielrohers/9692611 to your computer and use it in GitHub Desktop.
My JavaScript Module Pattern
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
;(function (w, d, undefined) { | |
'use strict'; | |
var app = (function () { | |
var exports = {}; | |
var _privateMethod = function () { | |
return 'private method'; | |
}; | |
exports.publicMethod = function () { | |
return 'public method'; | |
}; | |
return exports; | |
})(); | |
w.app = app; | |
/* | |
this is possible: | |
app.publicMethod(); | |
this is not possible: | |
app._privateMethod(); | |
app.privateMethod(); | |
*/ | |
})(window, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment