https://www.jsv9000.app/ - event loop examples

What is queueMicrotask()?

queueMicrotask() lets you schedule a function to run at the end of the current call stack, before any macrotasks like setTimeout. It adds the function to the microtask queue, just like .then() from a resolved Promise.

queueMicrotask(() => {
  console.log('This runs after the current call stack, but before setTimeout');
});

✅ Goes into the microtask queue:

✅ Goes into the macrotask queue: