Javascript--15 rule parsing JavaScript Object layout (__proto__, prototype, constructor)

Source: Internet
Author: User

We all say that JavaScript properties are many, can not remember, various structures are difficult to understand. Indeed JS is a quick way to improve the difficult language, but there are other ways to assist the memory. The following is to discuss the JS of a major difficulty-object layout, exactly how the person who designed JS this language was how to do? What did you become when you finished the design?

Let's look at a picture:

I believe you are not unfamiliar with this picture, the constructor has a prototype attribute pointing to its prototype. The opposite prototype also has a constructor pointing to the constructor. At the same time the instance also has a constructor point to the constructor, which is simply tied to each other for fear of not finding it, is it?

There is also a __proto__ attribute that we call the secret link, forgive me to see this attribute at first sight to feel special strange, _ Underline all use, hump naming rule? OK, this is a part of the browser exposed to a pointer, maybe when the design was casually written out, suddenly found that the goods a little use left (purely personal speculation).

The attached test code for the children's shoes can be played by themselves:

<! DOCTYPE html>

Above is only the basis, the following is the real focus, in order to modify this picture I was painstakingly, racked my brains, do not know how many brain cells died.

Maybe everyone has seen dizzy, nothing to take a cup of coffee slowly look. The following is the corresponding proof code, friendship tips Sublimetext look more cool:

<! DOCTYPE html>

I believe that after reading these code and the original comparison of the relationship between the JS object has been well-known, and indeed at the beginning I also let this goods dizzy dizzy, but after drawing this picture has felt nothing. You can draw it yourself.

Original address: Please click here

Javascript--15 rule parsing JavaScript Object layout (__proto__, prototype, constructor)

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.