Design patterns are reusable solutions to commonly occurring problems in software design. - Wikipedia

Reusing design patterns can speed up the software development process by providing us with tested and proven solutions to common development problems while ensuring that we write readable, reusable and maintainable codes

Over the lifespan of Javascript, many design patterns have been made and tested by a large number of developers using javascript. In this article, we would explain the common design patterns used by javascript developers.

Design patterns can be categorized into creational patterns, structural patterns, and behavioral patterns

Creational Pattern

Creational patterns focus on optimizing new object creation so as to suit the situation we are working it. The basic method for object creation might add some design complexities so these patterns help to remove such complexities.

Some of the patterns which under this category are:

Constructor pattern

Module pattern

Singleton pattern

Factory pattern

Prototype pattern

Structural Pattern

Structural patterns are concerned with how objects are made up and simplify relationships between different objects. These patterns ensure that objects are structured in a manner that when one part of the system changes, the entire structure of the system doesn't need to do the same. Patterns that belong to this category are:

Decorator Facade Flyweight



Behavioural Pattern

Behavioral design patterns are concerned with the assignment of responsibilities between objects and how objects communicate. Some behavioral patterns include:

Mediator

Observer

Command.

Note: Most of the examples used in this article are based on ES6

Constructor Pattern

Constructors are functions used to create a new instance of an object - both preparing the object for use and accepting arguments which the constructor can use to set the values of member properties and methods when the object is first created.