https://github.com/fbeline/design-patterns-JS/tree/master/src

Creational pattern:

Constructor:

creates objects through functions

the new keyword:

  • Creates a brand new object
  • Links to an object prototype
  • Binds this to the new object scope. Implicitly returns this

Module pattern:

object literal

  • simple way to encapsulate methods
  • creates a toolbox of functions to use

Factory pattern:

simplifies object creation

  • Simplifies object creation
  • Creating different objects based on need
  • Repository Creation

Singleton

Used to restrict an object to one instance of that object across the application.

  • Remembers the last time you used it
  • Hands the same instance back
  • Node.js uses CommonJS

Table of Contents