JavaScriptBeginner#async

What is callback hell and how do you avoid it?

Deeply nested callbacks that become unreadable and hard to error-handle. Flatten it with named functions, promises, or async/await.

Example
// callback hell
getUser(id, u => getOrders(u, o => getItems(o, i => render(i))));
// modern
const u = await getUser(id);
const o = await getOrders(u);
render(await getItems(o));

Related Questions

1
JavaScriptIntermediate#dom#events

What is event bubbling, capturing and delegation?

Open
2
JavaScriptIntermediate#dom#events

Difference between stopPropagation and preventDefault?

Open
3
JavaScriptAdvanced#performance#functions

What is debouncing and throttling?

Open