/JavaScript-design-patterns

Examples of popular design patterns in JavaScript

Primary LanguageJavaScriptMIT LicenseMIT

JavaScript design patterns

GitHub license

A collection of working design pattern examples and links to useful resporces where you can learn more about the design pattern and how to use it in JavaScript.

You will find explanations for each pattern in this Medium article: https://tomanagle.medium.com/software-design-patterns-in-javascript-7b329e14aa48

If you would like further explanation of a pattern, think an example can be improved or spot something is just wrong, please submit a pull request.

Creational

  • Constructor pattern
  • Class pattern
  • Module pattern
  • Factory pattern
  • Singleton pattern

Code examples

Structural

  • Decorator pattern
  • Facade pattern
  • Flyweight pattern

Code examples

Behavioral

  • Observer pattern
  • Mediator pattern
  • Command pattern

Code examples

|-- behavioral
|   |-- mediator.js
|   |-- observer.js
|   |-- README.md
|   |-- __TEST__
|       |-- observer.test.js
|-- creational
|   |-- class.js
|   |-- constructor.js
|   |-- factory.js
|   |-- module.js
|   |-- README.md
|   |-- singleton.js
|   |-- __TEST__
|       |-- class.test.js
|       |-- constructor.test.js
|       |-- factory.test.js
|-- structural
    |-- decorator.js
    |-- facade.js
    |-- flyweight.js
    |-- README.md