JS's prototype

Source: Internet
Author: User


Prototype and prototypes are two different things, and he's just a preset attribute on Foo. A prototype is a property on an object that points to Foo. Then we can make the shared variable or method by the method of the prototype assignment, like the X assignment on the top.

Method parsing:
1,object.create ()

method creates an empty object that has the specified prototype and several specified properties;

such as Student.prototype=object.create (Persion.prototype );

do not let student instances of __PROTO__ also have those unnecessary methods

student can define the same method as Persion, which is equivalent to rewriting the method in Persion




Instance:

Analytic diagram


Prototype the effect of the modification of the property value on the object before and after creation

1. Effect of property value modification on a created object

2. For objects created later

determines whether the property is again modified in the object


JS's prototype

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.