🎉 We just launched our new React course! Get it with 20% off! 🎉
What is the Event Loop?

What is the Event Loop?

Ferenc Almasi • 2021 January 08 • 📖 1 min read

In one single sentence, moving events from the task queue to the call stack is called the “event loop”. But in order to fully understand how the event loop works, you also need to understand three other things in JavaScript:

  • The stack: The order in which your code is being executed, is handled by the call stack. You can think of it as an array that holds a list of command on what to execute next.
  • The web API thread: Everything that is not part of the JavaScript engine, is handled by a separate thread. Think of the various functions you get in the browser, such setTimeout or a Promise.
  • The task queue: Everything that is waiting to be executed is stored in the task queue. Such as a callback funcion from a setTimeout. Until the task queue is empty again, the event loop will process the next message in the queue and puts it into the stack.
What is the event loop in JavaScript?
If you would like to see more Webtips, follow @flowforfrank

What is The Event Loop in JavaScript?
Looking to improve your skills? Check out our interactive course to master JavaScript from start to finish.
Master JavaScript

Resources:

JavaScript Course Dashboard

Tired of looking for tutorials?

You are not alone. Webtips has more than 400 tutorials which would take roughly 75 hours to read.

Check out our interactive course to master JavaScript in less time.

Learn More

Recommended