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)

Explanation:
The isPrototypeOf() method tests for an object in another object’s prototype chain.
Object.prototype.isPrototypeOf()



Leave a Reply 4

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


Michał

Michał

The correct is [ClassNameOf(parentObj)].prototype.isPrototypeOf(testObj)

Michał

Michał

D option is nearest.