简体   繁体   English

全局执行上下文是由函数创建的吗?

[英]Is global execution context is created by function?

I was learning JS and execution contexts.我正在学习 JS 和执行上下文。 Also, I found out that there is a special execution context which is executed by default which is fglobal execution context.另外,我发现有一个默认执行的特殊执行上下文,即 fglobal 执行上下文。 The question is "Is global execution context a function which is executed behind the scenes"?问题是“全局执行上下文是否是在幕后执行的函数”?

It's not a function, it's an abstraction that holds certain information about the context within which javascript is running.它不是一个函数,它是一个抽象,它包含有关 javascript 运行的上下文的某些信息。 It is set up by the javascript engine before it starts to execute any code so it is created by a "function behind the scenes", but it is not itself a function.它在开始执行任何代码之前由 javascript 引擎设置,因此它是由“幕后函数”创建的,但它本身不是一个函数。 In the browser, the globsal execution context will include various functions and objects (like the document object).在浏览器中,全局执行上下文将包括各种函数和对象(如document对象)。 In node on the server, it will be something different.在服务器上的节点中,它会有所不同。 It is closely related to the global scope, but execution context and scope are not identical.它与全局作用域密切相关,但执行上下文和作用域并不完全相同。 It's quite a complex subject, so you may want to read this for more information: https://codeburst.io/js-demystified-04-execution-context-97dea52c8ac6这是一个相当复杂的主题,因此您可能需要阅读此内容以获取更多信息: https : //codeburst.io/js-demystified-04-execution-context-97dea52c8ac6

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM