When running the below code I am receiving a type error when passing my arguments. It seems I am unable to pass my JSON data as arguments to the Employee object.
This is the error I am receiving:
/home/ubuntu/test/tests/employee.js:4
this.name = params['name'] || "";
^
TypeError: Cannot read property 'name' of undefined
Below is the code:
//comment
var Employee = function (params) {
this.name = params['name'] || "";
this.dept = params['dept'] || "general";
}
function Manager () {
this.reports = [];
}
Manager.prototype = new Employee;
function WorkerBee (params) {
console.log("params "+params);
this.base = Employee;
this.base(params);
// this.projects = params['projs'] || [];
}
WorkerBee.prototype = new Employee;
function Engineer (params) {
this.base = WorkerBee;
this.base(params);
params['projs']="engineering";
// this.base(params['name'], "engineering", params['projs']);
this.machine = params['mach'] || "";
}
Engineer.prototype = new WorkerBee;
var jane = new Engineer({'name': "Doe, Jane", 'projs':["navigator", "javascript"], 'mach':"belau"});
console.log(jane);
Any guidance would be appreciated to correct this example.