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:
Is this one correct? Shouldnt it be D?
yeah it should be D
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf
+1
prototypeObj.isPrototypeOf(obj)
Parameters
prototypeObj
An object to be tested against each link in the prototype chain of the object argument.
object
The object whose prototype chain will be searched.
Its B 🙁
D. Parent to child.
Not D or B.
Correct answer: parentObject.prototype.isPrototypeOf(testObj);
C would be right if it was testObj instanceof parentObject;
I think it is D:
https://jsfiddle.net/3so2o51e/