Purpose is to improve the design pattern of the code clean, reducing the amount of code resource consumption.
JS design patterns can be divided into the following three types:
1. Create a design pattern
Description : focus on mechanisms to deal with objects created in an appropriate manner to create an object, in order to reduce the complexity of the process of creating an object.
Comprising : Constructor (builder), Factory (factory), Abstract (abstract), Prototype (prototype), Singleton (singleton), Builder (generator).
2. Structural Design Patterns
Description : Finding common ground between different objects, and to establish certain relationships; ensure that when a part of the system is changed, the overall structure of the system need not be changed at the same time.
Comprising : Dectorator (decorated), Facade (appearance), Flyweight (Flyweight), Adapter (adapter), Proxy (agent).
3. behavioral design patterns
Description : to improve or simplify the communication between different objects in the system.
It includes : Iterator (iterators), Mediator (Mediator), Observer (observers), Visitor (visitors).