JSFiddle - React, Tailwind, and code Playground

by samdelagarza

JavaScript

function Employee(name){
	this.name = name || '';
  this.dept = 'general';
  console.log('employee ctor run');
}

function Manager(name){
	Employee.call(this, name);
  // array of Employees
  this.reports = [];
}

function WorkerBee() {
	// array of strings
  this.projects =[];
}

function SalesPerson() {
	this.quota = 100;
  /*
  	overrides the dept property
  */
  this.dept = 'sales';
}

function Engineer() {
	this.machine = '';
  this.dept = 'engineering';
}


//Manager.prototype = new Employee();// Object.create(Employee.prototype);
//Manager.prototype = Employee.prototype;
Manager.prototype = Object.create(Employee.prototype);
Manager.constructor = Manager;
//WorkerBee.prototype = new Employee();
//SalesPerson.prototype = new WorkerBee();
//Engineer.prototype = new WorkerBee();

console.log('instantiating manager');
var m = new Manager('rob');

console.log('mgr: ', m);
console.log('dept: ', m.dept);
console.log('ctor: ', m.constructor);

console.log('instance: ', m instanceof Manager);

console.log(m.constructor)