Skip to main content
Version: 3.27.2

Object.prototype.isPrototypeOf()

The isPrototypeOf() method checks if an object exists in another object's prototype chain.

Note: isPrototypeOf() differs from the instanceof operator. In the expression object instanceof AFunction, object's prototype chain is checked against AFunction.prototype, not against AFunction itself.

Syntax

isPrototypeOf(object)

Parameters

  • object
    • : The object whose prototype chain will be searched.

Return value

A boolean indicating whether the calling object (this) lies in the prototype chain of object. Directly returns false when object is not an object (i.e. a primitive).

Errors thrown

Description

All objects that inherit from Object.prototype (that is, all except null-prototype objects) inherit the isPrototypeOf() method. This method allows you to check whether or not the object exists within another object's prototype chain. If the object passed as the parameter is not an object (i.e. a primitive), the method directly returns false. Otherwise, the this value is converted to an object, and the prototype chain of object is searched for the this value, until the end of the chain is reached or the this value is found.