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...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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 hassetImmediate
. For more information about browser throttling: developer.mozilla.org/en-US/docs/W...