Functional pattern

Functional pattern

Function User(name) {
  this.sayHi = function() {
    alert(name);
  };
}

let user = new User("John");
user.sayHi(); // John
  • The constructor function below can be considered a "class" according to the definition.
  • It is a "program-code-template" for creating objects (callable with new).
  • It provides initial values for the state (name from parameters).
  • It provides methods (sayHi).

Functional pattern — Structure map

Clickable & Draggable!

Functional pattern — Related pages: