๐ฐmodule pattern
JS โฉ module โฉ module pattern
was used as a module system before the introduction of native JavaScript modules, implemented using IIFE.
replit๏ผmodule pattern
// โญ๏ธ object returned by IIFE
// โญก
// โญ โฎ โญโโโโโโโโโโโ โญ๏ธ IIFE โโโโโโโโโโโโโฎ
const foo = (function() {
// internal function
function sayHi(name) {
console.log(`Hey, my name is ${name}`);
}
// โญ๏ธ exposing the variables
return { sayHi };
})();
// โญ๏ธ accessing exposed methods
foo.sayHi("Bar");Last updated
Was this helpful?