I am following MDN guide about adding property and this is what my code looks like
'use strict';
function Employee() {
this.name = '';
this.dept = 'general';
}
Employee.prototype.specialty = 'none';
function Manager() {
Employee.call(this);
this.reports = [];
}
Manager.prototype = Object.create(Employee.prototype);
Manager.prototype.constructor = Manager;
function WorkerBee() {
Employee.call(this);
this.projects = [];
}
WorkerBee.prototype = Object.create(Employee.prototype);
WorkerBee.prototype.constructor = WorkerBee;
function SalesPerson() {
WorkerBee.call(this);
this.dept = 'sales';
this.quota = 10;
}
SalesPerson.prototype = Object.create(WorkerBee.prototype);
SalesPerson.prototype.constructor = SalesPerson;
function Engineer() {
WorkerBee.call(this);
this.dept = 'engineering';
this.machine = '';
}
Engineer.prototype = Object.create(WorkerBee.prototype);
Engineer.prototype.constructor = Engineer;
let mark = new WorkerBee;
console.log(mark);
mark.name = 'Doe, Mark';
mark.dept = 'admin';
mark.projects = ['navigator'];
console.log(mark);
mark.bonus = 3000;
console.log(mark);
When I run this, I do not see specialty
property for mark
object.
WorkerBee { name: '', dept: 'general', projects: [] }
WorkerBee { name: 'Doe, Mark', dept: 'admin', projects: [ 'navigator' ] }
WorkerBee {
name: 'Doe, Mark',
dept: 'admin',
projects: [ 'navigator' ],
bonus: 3000 }
What am I missing?
Thanks
UPDATE
As per @adiga answer, I was able to locate the specialty
property in the prototype chain.