javascript-patterns Blogs
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
Kiprosh is now part of LawLytics
Written by Kiprosh, team of passionate and disciplined craftsmen turning your ideas into reality.
JavaScript modules are the most used design pattern to keep your code separate from your components which provides loose coupling to your code. Modules are JavaScript classes, which provides protection of states and behaviours from being accessed by other classes. The module pattern allows for public and private access levels. This is how the code looks like: (function() { // declare private variables and/or functions return { // declare public variables and/or functions } })(); Here we have to instantiate the private variables and functions before returning our object. Code outside of our function is unable to access these private variables since it is