2. The Global Execution Context.
3. The Local or Function Execution Context.
When a function is invoked, a Local Execution Context is created. The responsibility of this context is to parse the called function and return the result to our global environment.
4. The Call Stack.
5. The Queue.
Putting It All Together.
To demonstrate the Queue, I've used
setTimeout() from our browsers Web API. I've set the timeout to zero on both instances, to show that it won't impact the order of our logs even though there isn't an actual delay.
- What the Heck is the Event Loop Anyway? by Philip Roberts
- JavasScript Call Stack What It Is and Why It's Necessary by Charles Freeborn
- Introduction to Functions, Execution Context and the Call Stack by Code Smith
- The JS Call Stack Explained in 9 Minutes by Colt Steele