Last active
October 25, 2021 16:20
-
-
Save iknowkungfoo/1028d480bf7083c9cef7567bd35b79ff to your computer and use it in GitHub Desktop.
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
FOO.moduleName = function () { | |
// Private variables, global to the module. | |
let fieldX; // This value will be changed. | |
const foo; // This value will not change. | |
/** | |
* Constructor | |
*/ | |
const init = () => { | |
fieldX = document.getElementById('fieldX'); | |
} | |
// https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event | |
// The DOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed, | |
// without waiting for stylesheets, images, and subframes to finish loading. | |
// Call the constructor when the DOM is ready. | |
document.addEventListener("DOMContentLoaded", init); | |
/** | |
* Can't be called externally. | |
*/ | |
const privateFunction = () => { | |
const fieldY = document.getElementById('fieldY'); | |
const fieldXvalue = fieldX.value; | |
} | |
/** | |
* Will be returned by the module, to be called externally. | |
*/ | |
const publicFunction = () => { | |
} | |
return { | |
publicFunction: publicFunction | |
} | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment