JS Built-ins
← Object128 / 150
ObjectisPrototypeOfbeginner

isPrototypeOf() β€” unrelated objects

πŸ“– Usage Example
// Check prototype chain membership
const proto = {}
const child = Object.create(proto)
proto.isPrototypeOf(child)   // β†’ true
Object.prototype.isPrototypeOf(child)  // β†’ true

Use isPrototypeOf() to check whether an object exists anywhere in the prototype chain of another object.

isPrototypeOf() β€” returns false for unrelated objects

If the object you're testing is not in the prototype chain at all, isPrototypeOf() returns false.

Challenge: Confirm that unrelated objects return false from isPrototypeOf().

πŸ’‘ Hints (1)
  • β€’ isPrototypeOf returns false if no relationship exists