Functions and usages of isprototypeof function in JavaScript

Source: Internet
Author: User

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.

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.