Created
June 19, 2014 17:49
-
-
Save ryands/9374b402f34feeff17f7 to your computer and use it in GitHub Desktop.
JS Module pattern - quick example
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
/* 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