Which method or operator should you add to the function?

You are creating a custom function. You pass an object named testObj to the function as a
parameter. You do not use inheritance through the functions.
The function must establish whether testObj inherits from another object named parentObj.
You need to ensure that the function performs as required.
Which method or operator should you add to the function?

You are creating a custom function. You pass an object named testObj to the function as a
parameter. You do not use inheritance through the functions.
The function must establish whether testObj inherits from another object named parentObj.
You need to ensure that the function performs as required.
Which method or operator should you add to the function?

A.
parentObj.instanceof(testObj)

B.
testObj.isPrototypeOf(parentObj)

C.
testObj.instanceof(parentObj)

D.
parentObj.isPrototypeOf(testObj)



Leave a Reply 14

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


conor

conor

which is the answer then? Is anyone 100% sure..

Mil

Mil

I am confused. which is the correct annswer B or D?

MG

MG

I think that none of the answers is correct.
Based on the articles you linked the right answer would be:
parentObj.prototype.isPrototypeOf(testObj)

Damien

Damien

Compare M’s linked example with this example:

Here we have: parentObj.isPrototypeOf(testObj)
In M’s link: subProto.isPrototypeOf(sub)

MG is wrong because the question specifically says “You do not use inheritance through the functions.”

M is correct. The answer is D.

Sihle

Sihle

D is the correct answr hence testObj is an object that is passed so B is wrong

Viviana

Viviana

The answer is D

R

R

B is correct.

prototypeObj.isPrototypeOf(object)

Parameter – object
The object whose prototype chain will be searched.

In this case, parentObj’s prototype chain will be searched.