Functions and examples of isPrototypeOf functions in JavaScript

Source: Internet
Author: User

Functions and examples of isPrototypeOf functions in JavaScript

This article mainly introduces the functions and examples of isPrototypeOf functions in JavaScript. This article describes the functions, usage methods, and examples of isPrototypeOf functions. For more information, see

In JavaScript, The isPrototypeOf function method returns a Boolean value indicating whether the object exists in the prototype chain of another object. Usage:

The Code is as follows:

Object1.isPrototypeOf (object2)

Object1 is a required instance of an object.

Object2 is required. Another object will check its prototype chain.

If the prototype chain of object2 contains object1, The isPrototypeOf Function Method in JavaScript returns true.

The prototype chain can be used to share functions between different instances of the same object type.

If object2 is not an object or object1 does not appear in the prototype chain of object2, The isPrototypeOf Function Method in JavaScript returns false.

The following example describes how to use the isPrototypeOf function in JavaScript.

The Code is as follows:

Function test (){

Var re = new RegExp (); // initialize the variable.

Return (RegExp. prototype. isPrototypeOf (re); // return true.

}

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.