r/learnjavascript • • May 01 '20

Async vs. Sync

Post image
413 Upvotes

81 comments sorted by

View all comments

75

u/ramsncardsfan7 May 01 '20 edited May 01 '20

This is only one specific perspective that could be misleading. You can have the same graph using only asynchronous calls. On the left you could have synchronous asynchronous (one promise after another) and on the right you could have asynchronous asynchronous (Promise.all).

What I’m trying to say is that just because your calls are asynchronous doesn’t mean they are happening at the same time. You have to do that purposefully.

4

u/MrEscobarr May 01 '20

Thats why I was so confused about the async/await. Like the name is async but you wait for it to finish so it didnt make sense to me

3

u/NoStranger6 May 02 '20

Well you wait for it to complete the rest of your function. Meanwhile, the browser is free to execute whatever it has queued.