Callback Hell:

Aymenkaabi
1 min readSep 23, 2020

Asynchronous JavaScript, or JavaScript that uses callbacks, is hard to get right intuitively.

The cause of callback hell is when people try to write JavaScript in a way where execution happens visually from top to bottom. Lots of people make this mistake! In other languages like C, Ruby or Python there is the expectation that whatever happens on line 1 will finish before the code on line 2 starts running and so on down the file. As you will learn, JavaScript is different.

  • How do I fix callback hell?

Callback hell is caused by poor coding practices. Luckily writing better code isn’t that hard!

  • Keep your code shallow
  • Modularize
  • Handle every single error

And that’s it :)

--

--