JS Built-ins
← Object126 / 150
ObjectisPrototypeOfbeginner

isPrototypeOf() β€” basics

πŸ“– 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.

Object.prototype.isPrototypeOf()

proto.isPrototypeOf(obj) returns true if proto appears anywhere in the prototype chain of obj.

Challenge: Implement checkPrototype(proto, obj) that returns whether proto is in obj's prototype chain.

πŸ’‘ Hints (1)
  • β€’ isPrototypeOf traverses the entire prototype chain