Last active
December 22, 2015 21:39
-
-
Save maur8ino/6534535 to your computer and use it in GitHub Desktop.
Javascript module template
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
$(document).ready(function() { | |
// Calling module(s) | |
$M.myModule(); | |
var module2 = new $M.myModule2(); | |
module2.myPublicFunction(); | |
if (someCondition) { | |
$M.myModule3(); | |
} | |
}); |
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
(function() { | |
var myPrivateVar1, | |
myPrivateVar2; | |
function myModule() { | |
/* | |
Module init | |
*/ | |
} | |
function myPrivateFunction() { | |
/* | |
private function logic | |
*/ | |
} | |
myModule.prototype = { | |
myPublicFunction1: function(params) { | |
/* | |
can access private function/vars | |
*/ | |
} | |
}; | |
$M = window.$M || {}; | |
$M.myModule = myModule; | |
window.$M = $M; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment