What is Callback Hell ?
- Callback Hell happens when multiple nested callbacks are used in asynchronous code, making it hard to read, understand, and maintain.
- It usually looks like a pyramid or Christmas tree shape because of too many levels of indentation.
Example :
// Nested callbacks (Callback Hell)
setTimeout(() => {
console.log("Step 1");
setTimeout(() => {
console.log("Step 2");
setTimeout(() => {
console.log("Step 3");
}, 1000);
}, 1000);
}, 1000);
Top comments (0)