DEV Community

Discussion on: ⭐️🎀 JavaScript Visualized: Promises & Async/Await

Collapse
 
spoike profile image
Mikael Brassman • Edited

Loving the article and the visualizations!

There is a gotcha however, setTimeout(..., 0) will not immediately put the task to the macrotask queue because of browser throttling. While the result will be the same, the reason why setTimeout fires last is because it is queued up in the macro task queue "a lot" later (4ms) rather than it being a macro task.

That setTimeout is throttled is why Node environment has setImmediate. For more information about browser throttling: developer.mozilla.org/en-US/docs/W...