Callback Hell
ELI5 — The Vibe Check
When your JavaScript code has so many nested callbacks it looks like a pyramid (or a sideways Christmas tree). Each callback is inside another callback inside another callback. It was a huge problem before Promises and async/await saved us all. Also called 'the pyramid of doom.'
Real Talk
Callback hell (or the pyramid of doom) is a coding anti-pattern where deeply nested callback functions create code that's difficult to read, debug, and maintain. It was common in Node.js before Promises and async/await provided flatter, more readable asynchronous patterns.
Show Me The Code
// Callback hell 😱
getUser(id, (err, user) => {
getOrders(user.id, (err, orders) => {
getDetails(orders[0].id, (err, details) => {
sendEmail(user.email, details, (err, result) => {
console.log('finally done!')
})
})
})
})
// Modern async/await 😌
const user = await getUser(id)
const orders = await getOrders(user.id)
const details = await getDetails(orders[0].id)
await sendEmail(user.email, details)
When You'll Hear This
"Refactor this callback hell into async/await." / "Callback hell is why Promises were invented."
Related Terms
Anti-Pattern
Anti-Pattern is the opposite of a design pattern — it's a commonly used approach that looks like it solves a problem but actually makes things worse.
Async/Await
Async/await is syntactic sugar that makes Promises look like normal, readable code. Instead of chaining .then().then().
Callback
A callback is just a function you pass to another function, saying 'when you're done, call this.
Promise
A Promise is JavaScript's way of saying 'I'll give you a value eventually — it's not ready yet, but I promise.