The isPrototypeOf function method in JavaScript is to return a Boolean value indicating whether the object exists in the prototype chain of another object. How to use:
Copy Code code as follows:
Object1.isprototypeof (OBJECT2)
Where Object1 is a required option, an instance of an object.
Object2 is required, and another object is going to check its prototype chain.
If Object2 's prototype chain contains Object1, then the isPrototypeOf function method in JavaScript returns TRUE.
A prototype chain can be used to share functionality between different instances of the same object type.
If Object2 is not an object or Object1 does not appear in the prototype chain in Object2, the isPrototypeOf function method in JavaScript will return false.
The following example illustrates the use of the isPrototypeOf function method in JavaScript.
Copy Code code as follows:
function Test () {
var re = new RegExp (); Initializes the variable.
Return (RegExp.prototype.isPrototypeOf (re)); Returns True.
}