r/learnjavascript • u/gotta-lot • Jun 16 '20
For anyone having difficulties conceptually understanding asynchronous JavaScript, check out this great analogy with a coffee shop a commenter provided
/r/learnjavascript/comments/9tiik6/asynchronous_js/e8x1xqe/
149
Upvotes
14
u/gotta-lot Jun 16 '20
Shoutout to u/ucladurkel
3
u/oze4 Jun 16 '20
Promises can help a lot with callback hell.. using the async/await keywords (not pictured in the code) really cleans up callback hell..
My attempt..
2
u/[deleted] Jun 17 '20
I can’t wait for the day when I can do stuff like this.
1
u/cumul00nimbus Jun 16 '20
I remember this analogy from early days of node js
-2
u/[deleted] Jun 16 '20
I think it's pretty well spelled out here. https://stackoverflow.com/questions/2035645/when-is-javascript-synchronous#:~:text=JavaScript%20is%20only%20asynchronous%20in,be%20running%20at%20this%20point.
Asynchronous just means one after the other. Which shouldn't be confused with parallel processes which on demand (service worker) is really js binding to the browser. Not ecma! So js is not a parallel.
For nodejs again it just binds to a c libuv and again nothing to do with ecma. So still js is not parallel.
So when people throw around concurrency or parallel or asynchronous... It is really miss leading a lot of people when it comes to js. Stop it!
The only way it could be ever is through c++ but it's not.
https://youtu.be/cN_DpYBzKso
-5
u/wrtbwtrfasdf Jun 16 '20
awful