Created
July 12, 2013 17:33
-
-
Save pbrewczynski/5986229 to your computer and use it in GitHub Desktop.
Why we would like to do something like this, if jQuery (jQ) is anyway Global ?
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
// Global module | |
var myModule = (function ( jQ, _ ) { | |
function privateMethod1(){ | |
jQ(".container").html("test"); | |
} | |
function privateMethod2(){ | |
console.log( _.min([10, 5, 100, 2, 1000]) ); | |
} | |
return{ | |
publicMethod: function(){ | |
privateMethod1(); | |
} | |
}; | |
// Pull in jQuery and Underscore | |
}( jQuery, _ )); | |
myModule.publicMethod(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment