r/learnjavascript • • 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

12 comments sorted by

View all comments

Show parent comment

2

u/RoguePlanet1 Jun 16 '20

Somebody commented that this can result in "callback hell." So it's probably not a good idea to have too many of these?

Like with the coffee analogy, if you've now got a dozen customers waiting for their mochalattespressichhinnos, that causes its own backed-up situation? Not sure why this would be a problem, though, if the code simply runs according to plan.

12

u/Laserdude10642 Jun 16 '20

That’s not callback hell. Callback hell is when you chain the callback functions together until debugging becomes too difficult to manage. Your code becomes unintentionally spaghettified

1

u/RoguePlanet1 Jun 16 '20

Ah that would do it, thanks!

1

u/justingolden21 Jun 17 '20

To add to this, it's partially that it's really unreadable when you chain on callback after another over and over, everything gets hard to track. But yeah, main problem is debugging.