The execution context refers to the environment where JavaScript code is executed.
It determines what variables and functions are accessible during the execution of the code.
Types of Execution Contexts
Global Execution Context (GEC)
This is the default or base execution context. It is where code that is not inside any function gets executed and where globally scoped variables reside. There is only one Global Execution Context in a JavaScript program.
Functional Execution Context (FEC)
This context is created by the execution of the code inside a function. Each function call creates a new FEC, and it includes the function's arguments, local variables, etc. It also has a reference to its outer environment, which helps in implementing lexical scope.
Components of Execution Context
It consist of a variable environment that stores variables and functions in the current context and a lexical environment that tracks variable references and relationships.
We will learn about the lexical environment and scope in the upcoming lessons.