Theoretically speaking, there are three major JS design pattern *types*:
Creational Design Pattern
As the name suggests, Creational Design Patterns focus on the creation of object or classes. This is important in large applications where object creation needs to be controlled.
Creational Design Patterns work through the medium of classes and objects where class involves a factory method in which an instance of several derived classes are created while objects employ abstract factory methods.
Structural Design Pattern
In the Structural Design Pattern, the focus is on the object composition. Thus, this design pattern looks for ways to manage object relationships such that the application is created in a scalable way and that a change in one part of the application does not affect other parts.
Structural Design Patterns also work through the medium of classes and objects where class involves adapter which matches interfaces of different classes so that they can work together despite incompatible interfaces.
Behavioral Design Pattern
It is important to understand that these designs patterns are not perfect while singly implemented. However, a familiarity with each of them is a prerequisite in helping developers make educated decisions based on the needs of their application.
The Module Design Pattern
The Module Design Pattern also has a variant: the Revealing Module Pattern. It is largely similar to the module pattern with only one contrary feature. In the Revealing Module Pattern, all the methods and variables are kept private until they are explicitly exposed, which extends a great advantage in the form of increased readability due to explicitly defined public methods and variables.
The Singleton Design Pattern
The Mediator Design Pattern
The focus of the Mediator Design Pattern is on a single object which, when implemented, becomes a shared resource throughout the different pieces of an application. As such, Mediator Pattern can be used to facilitate communication across the different features of an application as well as the individual sub-pieces within one feature. You can find a practical implementation of this design pattern in this gist.
However, regardless of complexity, it is the aim of every web developer to write a code that is maintainable, readable, and reusable. It is at this point that design patterns can prove useful.
Since a design pattern is nothing but a reusable software solution, it can be used to provide an organizational structure for your code, thereby making it more usable, scalable and maintainable. In other words, design patterns are established ways of programming that help facilitate maintainability, communication and performance of code.
If you are an existing JS developer, which design pattern do you employ in your apps and projects? Share your views in the comments below!