Design Patterns · Junior · Question 14 of 75
What is the Module pattern in JavaScript?
- ✓Correct answer: Encapsulation: private details are hidden, a public API is exported
- 2Splitting an app into microservices deployed on different servers
- 3Loading all of the app's code as one big file for speed
Explanation
Modules used to be made with IIFEs and closures; now ES modules are used: everything not exported is private. This reduces coupling and protects against name collisions in the global scope.