"Go" javascript scope chain

Source: Internet
Author: User
  1. The scope chain of JavaScript functions is defined as the scope chain and the run-time scope chain;
  2. When a function is defined, it has a property [[scope]] that identifies its definition scope chain, and defines the scope chain [[scope]] to abide by such rules: When a function is defined, the scope chain [[scope]] is always the execution scope chain of the external function where it resides;
  3. A global function defines a scope chain that contains only the properties of a window;
  4. A function's execution time scope chain is always defined when the head of the scope chain is pressed into the currently active object (it contains this,arguments, parameters, local variables);
  5. When the function executes, the variable addressing is always looked down from the top of the scope chain, so the global variable has the slowest addressing speed;
  6. When an internal function is executed, he is still able to access its full scope chain. This is the reason that closures can access variables defined by external functions that have ended at run time;
  7. When a function execution encounters a with statement, all the properties of the object specified with the WITH specification are temporarily pressed at the top of the scope chain as the topmost of the scope chain;
  8. When a function execution encounters a catch, it temporarily presses the catch specified Error object at the top of the scope chain as the topmost of the scope chain;

More access

JavaScript Development Advanced: Understanding JavaScript scopes and scope chains

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.