Skip to main content
InterviewHubPRO
Section Overview
Q439

Question 439 of 536

Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)

82%
JavaScript & V8 Internals (536 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)

What is global execution context?

senior LevelMost AskedCode ExampleMemory Management

The global execution context is the default or first execution context that is created by the JavaScript engine before any code is executed(i.e, when the file first loads in the browser). All the global code that is not inside a function or object will be executed inside this global execution context. Since JS engine is single threaded there will be only one global environment and there will be only one global execution context.

For example, the below code other than code inside any function or object is executed inside the global execution context.

javascript
 var x = 10;

 function A() {
   console.log("Start function A");

   function B() {
     console.log("In function B");
   }

   B();
 }

 A();

 console.log("GlobalContext");