Last updated 2 years ago
Was this helpful?
โฉ โฉ module pattern
was used as a module system before the introduction of , implemented using IIFE.
closure as object
replit๏ผ
// โญ๏ธ 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");
CommonJS
MakeUseOf โฉ
YDKJS: Scope & Closures (v.2) > Ch. 8 >