You are creating a JavaScript object that represents a customer.
You need to extend the Customer object by adding the GetCommission() method.
You need to ensure that all future instances of theCustomer object implement the GetCommission() method.
Which code segment should you use?
A.
Option A
B.
Option B
C.
Option C
D.
Option D
I think there’s something wrong with that question. Every answer has on the left side “.GetCommission() = ” which is a method invocation and assignment is invalid. That cause a error “Customer.prototype.GetCommission is not a function”. Right answer should be without parentheses.
Ans: D
right unswer:
Customer.prototype.GetCommission = function()
{
alert(‘payroll’);
}
Yeah there isn’t a ()
The prototype property allows you to add new properties and methods to existing object types. for example,
function PrintStuff (myDocuments) {
this.documents = myDocuments;
PrintStuff.prototype.print = function () {
console.log(this.documents);