PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

A.
parentObj.instanceof(testObj)

B.
testObj.isPrototypeOf(parentObj)

C.
testObj.instanceof(parentObj)

D.
parentObj.isPrototypeOf(testObj)

14 Comments on “Which method or operator should you add to the function?

  1. Damien says:

    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.




    0



    0
  2. R says:

    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.




    0



    0

Leave a Reply