Did you know? 

Caffeine as a protective factor in dementia and Alzheimer's disease - https://pubmed.ncbi.nlm.nih.gov/20182054

Constructor pattern

Purpose: allows to create multiple instances on specific types of objects

Sample:

function EspressoMilk(coffee, ratio, oz){
    this.coffee = coffee;
    this.ratio = ratio;
    this.oz = oz;

    this.toString = function(){
    return this.coffee + " has " + this.ratio + " Espresso:Milk ratio and " + this.oz + " oz.";
    };
}

var macchiato = new EspressoMilk("Macchiato", "2:1", 3);
var cappuccino = new EspressoMilk("Cappuccino", "1:2", 6);
var latte = new EspressoMilk("Latte", "1:3", 8);


console.log( macchiato.toString() );
console.log( cappuccino.toString() );
console.log( latte.toString() );

Output:

Macchiato has 2:1 Espresso:Milk ratio and 3 oz.
Cappuccino has 1:2 Espresso:Milk ratio and 6 oz.
Latte has 1:3 Espresso:Milk ratio and 8 oz.

Command Pattern

Purpose: separates the responsibilities of issuing commands from anything executing commands and delegating this responsibility to different objects instead

Sample

var coffeeEquipment = {

  // request information
  requestInfo: function( model, id ){
    return "Information for " + model + " with ID " + id ;
  },
  
  // purchase coffee equipment
  buyEquipment: function( model, id ){
    return "You have purchased a " + model + " item with ID " + id ;
  },
  
  // request a demo
  requestDemo: function( model, id ){
    return "You have successfully request a demo for " + model + " with ID  " + id ;
  }

}


coffeeEquipment.execute = function ( name ) {
    return coffeeEquipment[name] && coffeeEquipment[name].apply( coffeeEquipment, [].slice.call(arguments, 1) );
};


console.log(coffeeEquipment.execute( "requestInfo", "siphon", "00001" ));
console.log(coffeeEquipment.execute( "buyEquipment", "french press", "00002" ));
console.log(coffeeEquipment.execute( "requestDemo", "V60", "00003" ));

Output:

Information for siphon with ID 00001
You have purchased a french press item with ID 00002
You have successfully request a demo for V60 with ID  00003

Decorator pattern

Purpose: code reuse and flexible alternative to subclassing

Sample:

// espresso
function coffeeEspresso() {
this.cost = function() {
    return 100;
    }
}

// espresso + ice cream
function coffeeAffogato(coffeeEspresso){
    var espresso = coffeeEspresso.cost();
    coffeeEspresso.cost = function() {
        return espresso + 50;
    }
}

// espresso + con panna
function coffeeConPanna(coffeeEspresso){
    var espresso = coffeeEspresso.cost();
    coffeeEspresso.cost = function() {
        return espresso + 50;
    }
}

//espresso + steamed milk + milk foam
function coffeeLatte(coffeeEspresso) {
    var espresso = coffeeEspresso.cost();
    coffeeEspresso.cost = function() {
        return espresso + 100;
    }
} 

Sample Usage:

cp = new coffeeEspresso();
coffeeEspresso(cp);
console.log( cp.cost() );

Output:

100 

Another Sample Usage:

cp = new coffeeEspresso();
coffeeLatte(cp);
console.log( cp.cost() );

Output:

200 

//to be continued...