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

How does Js store the execution context

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "how to store execution context in Js". In daily operation, I believe many people have doubts about how to store execution context in Js. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to store execution context in Js". Next, please follow the editor to study!

1. Execution context exists in the data stack. The stack holds all the contexts in which the code is run.

The stack is characterized by last-in, first-out, and each time a new context is created, it is pushed into the top of the stack. When the function execution is complete, the context pops up from the stack and the control process reaches the next context in the stack.

2. When the js engine first touches the script, it creates a global context and pushes it into the stack.

Example

/ / create a global context, enter the context execution stack var name = 'globalName';function F1 () {/ / after the first phase is carried out / / where this points to window / / name is created, but not assigned / / F2 is created and references console.log (name); / / then it should be undefined console.log (F2); / / this should be F2 var name =' f1ame' / / after that, name can access function F2 (argumentName) {console.log (argumentName);} / create F2 context, enter the context execution stack similarly F2 (name); / / F2 exit stack console.log (sex); / / sex is not created, not assigned, and there is no scope chain, so error sex not defined} / / create F1 context, enter the context execution stack F1 () / / F1 stack / / the global context is out of stack at this point, the study on "how to store execution context in Js" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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