JavaScript Internals (521 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)
What is function execution context?
Whenever a function is invoked, the JavaScript engine creates a different type of Execution Context known as a Function Execution Context (FEC) within the Global Execution Context (GEC) to evaluate and execute the code within that function.
Practical Code Example
javascript
// Function Execution Context: Created whenever a function is invoked.
// Contains:
// 1. Lexical Environment (parameters, local variables)
// 2. Variable Environment
// 3. 'this' value binding determined at call time
function greet(user) {
const msg = 'Welcome';
return `${msg}, ${user}`;
}
greet('Alice'); // Pushes new Function Execution Context to Call Stack