Design Patterns · Junior · Question 42 of 75
What is callback hell, and how is it avoided?
- ✓Correct answer: Deeply nested async callbacks; solved with promises and
async/await - 2Too many event handlers on the page; solved with
React.memo - 3Errors inside callbacks; solved by wrapping the call in
try/catch
Explanation
A "pyramid" of nested callbacks is hard to read and to handle errors in. Promises flatten the chain, and async/await makes async code look synchronous.