Skip to content

Instantly share code, notes, and snippets.

@Alexisvt
Last active August 10, 2023 15:38
Show Gist options
  • Save Alexisvt/7a4c612275255246ba4180243127c48a to your computer and use it in GitHub Desktop.
Save Alexisvt/7a4c612275255246ba4180243127c48a to your computer and use it in GitHub Desktop.
What is the Event loop in JavaScript - study notes

What is the Event loop in Javascript

JavaScript code runs single threaded. There is just one thing happening at a time.

This is good because devs dont need to worry about concurrency issues, the only caveat is to know how not to block that single thread like synchronous network calls or infinite loops.

In most browser there is an event loop for every browser tab, in other words, the environment manages multiple concurrent event loops, to handle API calls for example, Web Workers run in their own event loop as well.

You mainly need to be concerned that your code will run on a single event loop, and write code with this thing in mind to avoid blocking it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment