• 0 Posts
  • 92 Comments
Joined 1 year ago
cake
Cake day: July 1st, 2023

help-circle

















  • Yeah, that’s a big simplification and I get it. But the async syntax itself syntax “sugar” for Promises. It’s not like C# or Java/Android where it will spawn a thread. If you take a JSON of 1000 rows and attach a promise/await to each of them, you won’t hit the next event loop until they all run to completion.

    It’s a common misconception that asynchronous means “run in background”. It doesn’t. It means run at end of current call stack.

    Prior to that, the browser had window.setTimeout and its callback for delays and animation and such - but that’s it.

    And you STILL have to call setTimeout in your async executions or else you will stall your UI.

    Again async is NOT background. It’s run later. async wraps Promise which wraps queueMicrotask.

    Here is a stack overflow that explains it more in detail.