There is always one currently executing context. The rest are stacked below.

After the function is finished executing the stack is removed from the top and the code control flow returns to the previous / uppermost execution context.

In other words its a LIFO (Last In First Out) order.

Noteworthy: This “stacking” occurs only when you call a function from the scope of another function. And that function, yet calls another one from its own scope. Thus, creating not only a stack of, but also a chain of contexts tied by the this object — related to the scope in which function was executed.

Stacking will not happen no matter how many function calls are made in the same Lexical Environment / scope. They all just push and pop within the same environment.

Hope this article was helpful. . . and the 🍰 cake’splanations delightful!

Sponsored by Learning Curve — independent book publishing company that provided these amazing illustrations for free.

You may want to also see this JavaScript Execution Context video tutorial: