JS Built-ins
← Object130 / 150
ObjectisPrototypeOfintermediate

isPrototypeOf() β€” vs instanceof

πŸ“– 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() β€” comparison with instanceof

instanceof checks if Constructor.prototype is in the chain. isPrototypeOf() is more flexible β€” you can check any object, not just constructor prototypes.

Challenge: Use isPrototypeOf() to replicate what instanceof checks.

πŸ’‘ Hints (1)
  • β€’ isPrototypeOf is more general than instanceof β€” it can check any prototype, not just constructor.prototype