Skip to content

Instantly share code, notes, and snippets.

@iknowkungfoo
Last active October 25, 2021 16:20
Show Gist options
  • Save iknowkungfoo/1028d480bf7083c9cef7567bd35b79ff to your computer and use it in GitHub Desktop.
Save iknowkungfoo/1028d480bf7083c9cef7567bd35b79ff to your computer and use it in GitHub Desktop.
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