JS Basic content Prototype and example

Source: Internet
Author: User
the understanding of prototypes; When we create a function, each function automatically generates a prototype (prototype) attribute, and this property is a pointer to an object, called a prototype object, in the function. The prototype object contains a constructor attribute, which can be referred back to the function when we add an attribute to the function, it is actually added to the prototype object, and when we create a new instance with the Neo operator, the new instance is the one that can share the properties in the prototype object. When we create a new instance, there is a prototype attribute in this instance, similar to the function, which is also a pointer to the prototype object of the function, but unlike the function, the instance can be added directly to the property, and the property in the function is added to the prototype object . The properties in the prototype object cannot be changed by overriding the properties in the instance, and when a new attribute is added to the instance, the new property is added to the instance without being added to the prototype object, and the property in the instance overrides the property when it is added to the instance with the same properties as the prototype object. Without changing the properties in the prototype object

  

JS Basic content Prototype and example

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.