Execution context (EC) is defined as the environment in which the JavaScript code is executed. By environment, I mean the value of this, variables, objects, and functions JavaScript code has access to at a particular time.
This is the default execution context in which JS code start its execution when the file first loads in the browser. All of the global code which is not inside any function or object is executed inside the global execution context. GEC cannot be more than one.
Functional execution context is created whenever it finds any function call. Each function has its own execution context. It can be more than one. Functional execution context has access to all the code of the global execution context though vice versa is not applicable.
Execution context inside eval function.
var a = 10; // (1)
function functionA() {
console.log("Start function A"); // (5)
function functionB(){
console.log("In function B"); // (4)
}
functionB(); // (3)
}
functionA(); // (2)
console.log("GlobalContext"); // (6)
💫 Call Stack (Execution stack)