Facebook Pixel

What are the bad parts of callbacks in JavaScript?

Callback hell (deep nesting), inversion of control (trust the function to call correctly), repetitive error handling (each callback must check), hard to run in parallel (manual counter), hard to cancel, and unclear stack traces.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in The Good and Bad Parts of Callbacks in JavaScript

Simplicity (pass a function, it gets called later), universality (work everywhere), synchronous use (map, filter, reduce), event handling (addEventListener), and closures (access outer variables).

Use callbacks for simple one-off calls (setTimeout), event listeners, synchronous array methods (map, filter), and old codebases. Use promises/async-await for chained async operations, parallel operations (Promise.all), and complex error handling.

Yes. When you pass a callback, 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

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.