Javascript Design Pattern

Javascript Design Pattern
    /* Design Pattern */
    
    
    var fn = function(){
          // todo
    }
    
    var obj = new fn('hello', 'world');
    // creational p[attern using 
    
    const obj = {}; // new Object();
    const object = Object.create(obj.prototype);
    
    var person = Object.create( Object.prototype );
     
    // Populate the object with properties
    defineProp( person, "car", "Delorean" );
    // creational design pattern
    class greetings {
        constructor(){ 
        }
        static sayHi(){   
        }
        sayHello(){  
        }
    }
    const object = new greetings();
     object.sayHello();
     greetings.sayHi();
     
     
    // module design pattern
    const module = (function(){
         // IIFE block 
         const privateVar = 'hello world';
         privateMethod(){
             return this.privateVar;
         }
        return {
            publicMethod : function(){
                return privateMethod();
            }
        }
    })();
    module.publicMethod();
    // factory pattern 
    class Computer{
        constructor(oprions){
            this.type = options.type || 'HP',
            this.configuration = option.configuration || 'I5 Octa Core'
        }
    };
    class Laptop{};
    class keyBoard{};
    class machineFactory {
        createMachine(options){
            if(options.type === 'computer'){
                return new Computer();
            }
    var personPrototype = {
        sayHi : function(){
            comsoel.log('say HI');
        }
    }
    function Person(name, age){
        name = name || 'john';
        age = age || 30;
        function constructorFunction(name, age){
            this.name = name;
            this.age = age;
        }
        constructorFunction.prototype = personPrototype;
        var instance = new constructorFunction(name, age)
    const myrevealingPattern = (function(){
          let privateVar = 'hello';
          const publicVar = 'hello world';
          function privareFn(){
              return privateVar;
          }
          function publicsetName(name){
              privateVar = name;
          }
          function publicGetName(name){
              return privareFn();
          }
          return {
               setName : publicsetName,
    const singelton = (function(){
        // IIFE
        let instance;
        function init(){
            return {
                x :90
            }
        }
        return {
            getInstance : function(){
                if(!instance){
                    instance = init();
                }
                return instance;
    // app.js
    export class hello {
        constructor(){}
    }
    //------------------// main.js //--------------//
    
    import blabla from
    
    // decorator pattern 
    
    function car(name){
        this.name = name;
        this.color = 'white';
    }
    var tesla = new car();
    tesla.setColor = function(color){
        this.color = color;
    }
    tesla.setprice = function(price){
        this.price = price;
    }
    tesla.setColor('blue');
    var invoker = {
        add : function(a,b){
            return a+b;
        },
        sub : function(a,b){
            return a-b;
        }
    }
    var manager = {
        execute : function(name, args){
            if(name in invoker){
                return invoker[name].apply(invoker, [].slice.call(args, 1));
            }
            return false;
    function *hello(){ yield 4;};
    
    var obj = hello();
    
    const arr = [1,4,2];
    arr.next() // 
    
    const iter = arr[Symbol.iterator]();
    iter.next(); // {value: 1, done: false}
    iter.next(); // {value: 4, done: false}
    iter.next(); // {value: 2, done: false}
    iter.next(); // {value: undefined, done: true}
    
    function *foo() {
    var iterator = (function(){
        var index = 0;
        data = [6,7,8,4,5,6,7,8];
        length = data.length;
        return {
           next : function(){
               var element;
               if(! this.hasNext){
                   return null;
               }
               element = data[index];
               index = index + 1;
               return element;
           },
    /* 
    This is a structural pattern where the interface of one class is tra
     This pattern lets classes work together that could not otherwise because 
     of incompatible interfaces
    */
    
    class oldCal {
        constructor(){
            this.operation = function(a,b,operation){
                switch(operation){
                    case 'add' :
                    return a+b;
                    case 'sub' :
                    return a-b;
    console.log("Hello from JavaScript");