- Refers to the situation where multiple nested callback functions are used to handle async operations, leading to deeply nested, hard-to-read, and hard-to-maintain code.
- It typically happens when one asynchronous function depends on the result of another, causing a chain of callbacks, sometimes called Pyramid of doom.
- To avoid it, Promises Javascript and later Async Await Javascript were introduced to make handling asynchronous code more readable & manageable.
Example
getUserData(userId, function(user) {
getPosts(user, function(posts) {
getComments(posts, function(comments) {
// more nested callbacks...
});
});
});