JS Built-ins
← Object129 / 150
ObjectisPrototypeOfintermediate

isPrototypeOf() β€” null prototype

πŸ“– 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() β€” null prototype objects

Objects created with Object.create(null) have no prototype. Object.prototype.isPrototypeOf() returns false for them.

Challenge: Verify that Object.prototype is not in the chain of a null-prototype object.

πŸ’‘ Hints (1)
  • β€’ Null-prototype objects have no inherited methods or prototype chain