liveBook · Manning

Execution context stack

As explained in Functional Programming in JavaScript

A stack of execution-context frames used by JavaScript to manage nested function calls and their associated execution state.

JavaScript uses an execution context stack to manage function calls. It starts with the global context; calling a function adds a frame, and returning removes it in last-in, first-out order. section 7.1

Each frame records a scope chain, variable object, and this value. Local variables and parameters make frames larger, while the scope chain links a function to its parent context and ultimately to the global context. section 7.1

Nested calls

When logger is invoked, JavaScript pauses the global context and activates logger’s frame. After logger returns, its frame is popped and the global context resumes. Nested functions, currying, and recursion add more frames and can increase stack use.

How Functional Programming in JavaScript covers it

How deep it goes
Explains LIFO behavior, frame contents, memory growth, and nested-call costs without detailing the complete runtime specification.
Examples
Uses logger invocation, curried addition, unbounded recursion, and recursive longest-string search to illustrate stack behavior.
What it assumes
Assumes basic JavaScript functions and closures, while introducing stacks, frames, scope chains, and execution state.
What you can do after
Diagnose stack-related performance problems by relating nested calls, currying, and recursion to execution-frame growth.
How it connects
Connects execution contexts with closures, scope chains, currying, recursion, and global context.

Also explained in

Compare how 8 books explain execution context stack →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in JavaScript. The section links point to the parts of the book it draws on.