employeeInheritance.js

    0

    0

    The Employee class has a prototype that contains the setTitle and getTitle methods. The Engineer class has a prototype that contains the setIsManager and getIsManager methods.

    function Employee(title) {
      this.title = title;
    }
    
    Employee.prototype.setTitle = function (title) {
      this.title = title;
    };
    
    Employee.prototype.getTitle = function () {
      return this.title;
    };
    
    function Engineer(title, isManager) {
      this.title = title;
      this.isManager = isManager;
    }
    
    Engineer.prototype = Object.create(Employee.prototype);
    
    Engineer.prototype.setIsManager = function (isManager) {
      this.isManager = isManager;
    };
    
    Engineer.prototype.getIsManager = function () {
      return this.isManager;
    };
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.