Last active
April 15, 2018 13:58
-
-
Save shobhitchittora/f04726d16f155019d72b35fc07365652 to your computer and use it in GitHub Desktop.
JS Design Patterns - MODULE - IIFE
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
// IIFE is an anonymous function which is called immediately. | |
const myModule = (function(){ | |
// private | |
const name = "my module"; | |
// public | |
return { | |
getName: function(){ | |
console.log(name); | |
} | |
}; | |
})(); | |
console.log(myModule.name); // undefined | |
console.log(myModule.getName()); // "my module" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment