Last active
August 29, 2015 13:57
-
-
Save cesarmiquel/9709930 to your computer and use it in GitHub Desktop.
This is a basic pattern for an extensible JavaScript module. This example is based off: http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html where you can find several more snippets.
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
var UTIL = (function (my, $) { | |
// private variables | |
var privateVariable = 1; | |
// private methods | |
function privateMethod() { | |
// ... | |
} | |
// public variables | |
my.moduleProperty = 1; | |
// public methods | |
my.moduleMethod = function () { | |
// You get access to jQuery | |
$('document').bind( ... ); | |
}; | |
return my; | |
}(UTIL || {}, jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment