Skip to content

Instantly share code, notes, and snippets.

@lstanard
Last active December 23, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lstanard/6584743 to your computer and use it in GitHub Desktop.
Save lstanard/6584743 to your computer and use it in GitHub Desktop.
JavaScript Design Pattern: Module Pattern - Example 02
// Methods available as myFunction.methodTest();
var myFunction = (function(){
var _root = this,
_config = {
'option': 'value'
},
_init = function() {
// Do something
};
return {
methodTest: function() {
// Do Something
},
methodTest2: function() {
// Do Something
},
methodTest3: function() {
// Do Something
}
};
_init();
}());
// If using jQuery, methods must be called from within a $(document).ready function
$(document).ready(function(){
myFunction.methodTest();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment