JS Coding Questions Logo
JS Coding Questions
#435💼 Interview💻 Code

What is global execution context?

Advertisement

728x90

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
1var x = 10;
2
3function A() {
4
5console.log("Start function A");
6
7function B() {
8  console.log("In function B");
9}
10
11B();
12}
13
14A();
15
16console.log("GlobalContext");

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 6

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
435of476