The Module Pattern

Going to js-module-pattern, the pattern is used to mimic classes in conventional software engineering and focuses on public and private access to methods & variables. The aim is to improve the reduction of globally scoped variables, thus decreasing the chances of collision with other code throughout an application.


  • Cleaner approach for developers
  • Supports private data
  • Less clutter in the global namespace
  • Localization of functions and variables through closures


  • Private methods are unaccessible.
  • Private methods and functions lose extendability since they are unaccessible.

 Another example of the module pattern that exposes the module a little differently and makes use of a shared private cache. This method encourages more of an object creation approach where we can optimize performance by being efficient with shared storage.