is the JavaScript scope chain linked to the prototype chain?

Source: Internet
Author: User

In general, the scope chain is for the variable, JS inside a large scope, there are only two scopes, global scope and function internal scope, if function 1 and define the function 2 (usually anonymous function), then there is a scope chain global scope ==> Function 1 scope = = > function 2 scope; Function 1 can directly use global scope variables, function 2 can directly use global scope and function 1 scope variables
The prototype chain is generally used when defining a constructor, which can be thought of as a constructor or a class corresponding to a constructor; the head of the prototype chain is the object class/constructor, if there is a constructor 1.prototype = constructor 2; Then there is a prototype chain; The Object ==> Constructor 1 ==> Constructor 2, the benefit is that the constructor 2 corresponds to the class, you can have the constructor 1 and the properties in object, JS does not correspond to the inheritance of the keyword, so use the prototype chain to simulate the effect of inheritance


Reference:http://zhidao.baidu.com/link?url=esm11qjkumyr0evqa6lilzsaq86_ 0dxuzqrpwdgzbaeif2pmfgawz-cgnngrjxovdqmjzcrpwxjsc9vbv3n8nq


is the JavaScript scope chain linked to the prototype chain?

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.