liveBook · Manning

Global execution context

As explained in Secrets of the JavaScript Ninja, Second Edition

The global execution context and its associated object value, which can serve as this in non-strict function calls without an explicit receiver.

JavaScript creates one global execution context when a program starts. It differs from a function execution context, which is created each time a function is invoked. The engine uses execution contexts to track code execution; a call stack keeps track of the active context and those waiting to resume. section 5.3

Figure 5.6. The behavior of the execution context stack

See how the execution context stack tracks function calls and returns. section 5.3

How Secrets of the JavaScript Ninja, Second Edition covers it

How deep it goes
Defines global and function execution contexts and their role in the call stack, without detailing their internal structure.
Examples
Shows repeated calls to skulk, which invokes report, to illustrate function execution contexts.
What you can do after
Understand how execution contexts track function calls and returns.
How it connects
Connects the global execution context to function execution contexts, the call stack, and single-threaded execution.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Secrets of the JavaScript Ninja, Second Edition. The section links point to the parts of the book it draws on.