Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Share the basics of JS

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "sharing the basics of JS". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's ideas to study and learn "sharing the basics of JS".

1. Execution environment: sometimes called environment, is one of the most important concepts in JavaScript. Execution environment defines other data that variables or functions have access to.

2. Variable object: each execution environment has a variable object associated with it, and all variables and functions defined in the environment are stored in this object.

3. Scope chain: when the code is executed in the environment, a scope chain of variable objects is created to ensure orderly access to all variables and functions that the execution environment has access to. The front end of the scope chain is always the variable object of the environment in which the code is currently executed.

4. Active object: if the current execution environment is a function, the active object is used as a variable object.

5. Executable code:

1) Global code: for example, loading external JS files or code within local tags. Global code does not include code inside the function.

2) function code: code in function body

3) eval code: the eval () function evaluates a string and executes the JS code in it, such as

Eval ("alert ('helloworld')").

6. Execution context stack: in a JS program, multiple execution contexts must be generated, and the JS engine will handle them as a stack, that is, the execution context stack.

7, scope: JS is a language without block-level scope (including the curly braces code blocks of if, for and other statements or individual curly braces code blocks can not form a local scope), so the formation of the local scope of js is formed by and only the code blocks defined in the function's curly braces, that is, the function scope.

8. Scope chain: it is the implementation of scope rules. Through the implementation of scope chain, variables can be accessed in its scope and functions can be called in its scope.

The scope chain is an one-way linked list, and each node on the linked list is the variable object of the execution context. the head of the one-way linked list (the first node that can be accessed) is always the variable object (active object) of the function being called and the tail is always the global active object.

9. Closure: function objects can be related to each other through the scope chain, and the data in the function body (variables and function declarations) can be stored in the function scope, which is called "closure" in the computer science literature.

From a technical point of view, the functions of JS are all closures: the functions are all objects, they are all associated with the scope chain, and the data in the function is saved in the scope of the function.

Thank you for your reading, the above is the content of "sharing the basic knowledge of JS". After the study of this article, I believe you have a deeper understanding of sharing the basic knowledge of JS, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report