/ #ffffff

JS Event Loop

Resources

Quotes

The Event Loop has one simple job — to monitor the Call Stack and the Callback Queue. If the Call Stack is empty, it will take the first event from the queue and will push it to the Call Stack, which effectively runs it.
JavaScript is a single-threaded programming language, which means it has a single Call Stack. Therefore it can do one thing at a time. The Call Stack is a data structure which records basically where in the program we are.

Notes

  • Function calls form a stack of frames within the Call Stack.
  • The Event Loop watches the Callback Queue and adds the frame to the Call Stack to be executed.
  • Returning from a function pops is off the Call Stack.
  • An Embedded iFrame has it's own call stack, postMessage is the only way to communicate between the two.