Why are promises better than callbacks in JavaScript?
Promises guarantee once-only settlement (no inversion of control), flatten chaining with .then instead of nesting, use one .catch for all errors, provide Promise.all for parallel operations, and enable async/await for synchronous-looking code.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Callback Hell Interview Questions in JavaScript
Deeply nested callbacks (pyramid of doom) that are hard to read, debug, and maintain. It happens when async operations depend on each other and each is nested inside the previous one's callback.
Use promises (.then chains) to flatten the nesting, or async/await to make async code look synchronous with try/catch for errors. If stuck with callbacks, use named functions instead of anonymous ones to keep the code flat.
When you pass a callback to a function, you give up control of when and how it is called. The function might call it multiple times, not at all, or with wrong arguments. Promises solve this by guaranteeing once-only settlement.
Still have questions?
Browse all our FAQs or reach out to our support team
