JSVerse
Core JavaScript / Execution Context

Execution Context

The environment a piece of code runs in — its variables, its scope, and what this means there.

Every time JavaScript runs code, it does so inside an execution context: a container holding that code's variables, its lexical environment (which scope chain it can see), and what `this` refers to there. The Global Execution Context is created once, when the program starts. A new Function Execution Context is created every single time a function is called — even calling the same function twice creates two separate contexts, each with its own variables.

Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
State
Step through — the console panel shows what's happening
Why?

Each call to add() builds a brand-new execution context with its own a, b, and sum — the two calls never see or interfere with each other's variables.