Last active
December 23, 2015 05:09
-
-
Save lstanard/6584743 to your computer and use it in GitHub Desktop.
JavaScript Design Pattern: Module Pattern - Example 02
This file contains 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
// 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