You are creating a class named Consultant that must inherit from the Employee class. The
Consultant class must modify the inherited PayEmployee method. The Employee class is
defined as follows.
function Employee() {}
Employee.prototype.PayEmployee = function ( ){
alertt’Hi there!’);
}
Future instances of Consultant must be created with the overridden method.
You need to write the code to implement the Consultant class.
Which code segments should you use? (Each correct answer presents part of the solution.
Choose two.)

A.
Consultant.PayEmployee = function ()
{
alert(‘Pay Consulant’);
}
B.
Consultant.prototype.PayEmployee = function ()
{
alert(‘Pay Consultant’);
}
C.
function Consultant () {
Employee.call(this);
}
Consultant.prototype = new Employee();
Consultant.prototype.constructor = Consultant;
D.
function Consultant() {
Employee.call(this); }
Consultant.prototype.constructor = Consultant.create;
I thought it was option C and D.
What’s wrong with option D?
0
0
In order to inherit objects you need to set child.prototype property.
(https://www.sitepoint.com/simple-inheritance-javascript/)
0
0