This article mainly introduces the functions and usages of isprototypeof function in JavaScript, this article explains its function and usage and use examples, the need of friends can refer to the following
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:
The code is 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.
The code is as follows:
function Test () {
var re = new RegExp (); Initializes the variable.
Return (RegExp.prototype.isPrototypeOf (re)); Returns True.
}