Mark As Completed Discussion

Callback Hell

"Callback hell" is state that code gets in. It's a problem created due to multiple nested callbacks. It is a very common anti-pattern in JavaScript, so let us take a closer look.

Imagine you are starting to build an application. The logic seems simple enough and you implement it using a few callbacks.

As you can see, with just three callbacks, the pyramid of doom (or the callback hell) is starting to take shape.

What if your application grows and the logic gets more and more complex? There is a high chance that the nesting from above can grow even further. In that case, it is safe to say that you're in callback hell.

JAVASCRIPT
1getSomething(function(x){
2    getSomethingElse(x, function(y){
3        getMoreOfSomethingElse(y, function(z){ 
4        });
5    });
6});