Which code segment should you use?

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?

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



Leave a Reply 5

Your email address will not be published. Required fields are marked *


JNash

JNash

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.

Vijayakumar S

Vijayakumar S

Ans: D

art

art

right unswer:
Customer.prototype.GetCommission = function()
{
alert(‘payroll’);
}

Adriano Alves

Adriano Alves

Yeah there isn’t a ()

cindy lou

cindy lou

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);