I'm trying to use the Revealing Module Pattern to scope the JavaScript on my page so that I don't pollute the global namespace.
<script type="text/javascript">
var myModule = (function(){
function windowLoad() {
// window onLoad things
return;
}
function otherFunc(){
// otherFunc things
}
window.onload = windowLoad;
return { otherFunc: otherFunc };
})();
myModule.otherFunc(); // myModule is undefined here
</script>
For some reason, as shown in the comment above, myModule
is undefined when I go to use it. Why?