I am Front-end Developer working in JavaScript. I am using the framework React. I am new to blogging and writing articles. I want to share my knowledge in the easiest possible way.
Handling Execution Context (Call Stack)
It is very difficult for JS to manage execution context but it manages it very beautifully. It manages the execution context creation/deletion, and control through call stack.
Note: If you don't know what execution context is, I really suggest you to read my previous blogs about it.
Now back to our topic:
The call stack is sometimes known as runtime stack, control stack, and execution context stack. So call stack maintains the order of execution of the execution context.
Let's see how this is done through the diagram.
Whenever a JS program is run its call stack is populated with Global Execution Context (GEC). Every time at the bottom of the call stack, we have GEC.

Now whenever a new function is invoked or a new execution context is created, that execution context is pushed into the stack.
After the work of this execution context is done, this execution context from the call stack is popped out and control goes back to the Global execution context.


After the whole program is done, the Global execution context also pops out from call stack and the call stack again becomes empty.
