Created
November 1, 2015 11:58
-
-
Save gtk2k/86a94fa531f2a9329c06 to your computer and use it in GitHub Desktop.
jQuery Module Design Pattern
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
** | |
* Module Design Pattern | |
* Import and Export | |
*/ | |
MODULE = (function ($) { | |
var my = {}; | |
var privateVariable = 'jQuery version '; | |
function privateMethod() { | |
// ... | |
} | |
my.moduleProperty = 1; | |
my.moduleMethod = function () { | |
alert(privateVariable + $().jquery) | |
// ... | |
} | |
return my; | |
}(jQuery)); | |
MODULE.moduleMethod() | |
console.log(MODULE.moduleProperty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment