Execution context for JavaScript

Source: Internet
Author: User

There are three kinds of code-running environments in javascript:

    • Global Code
      • Default environment for JavaScript code to start running
    • Function Code
      • Code into a JavaScript function
    • Eval Code
      • Executing code using eval ()

In order to represent a different runtime environment, JavaScript has a concept of an execution context (execution Context,ec) . That is, when the JavaScript code executes, it enters a different execution context, which forms an execution context stack (execution context stack,ecs).

For each execution context there are three important attributes, the variable object (Variable object,vo), the scope chain (scope chain), and this.

Variable objects are data scopes that are related to the execution context. It is a special context-sensitive object that stores the variables and function declarations defined in the context. In other words, the following information is included in the general VO:

    • Variable (var, Variable Declaration);
    • function declaration (Functions Declaration, FD);
    • Formal parameters of a function
    • function expression (relative to function declaration) not included in Vo
    • There are no variables declared with VAR (this variable is a "global" way of declaring, just adding a property to global, not in VO)

The activation object is created at the moment of entry into the function context, and it is initialized by the arguments property of the function.

    1. Callee: Reference to the current function
    2. Length: The number of parameters that are actually passed
    3. Properties-indexes: is the parameter value of the function (sorted from left to right by argument list)

Execution context for JavaScript

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.