Skip to content

Instantly share code, notes, and snippets.

@ryands
Created June 19, 2014 17:49
Show Gist options
  • Save ryands/9374b402f34feeff17f7 to your computer and use it in GitHub Desktop.
Save ryands/9374b402f34feeff17f7 to your computer and use it in GitHub Desktop.
JS Module pattern - quick example
/* Module pattern in javascript
* Not using RequireJS/ES6/Node/...
*/
var MyModule = (function () {
function SubClass() {
// constructor
}
SubClass.prototype.someMethod = function() {
// method
};
var blah = function() {
console.log('blah');
};
// export submodules/classes
return {
SubClass: SubClass,
blah: blah
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment