Login
Remember
Register
Ask a Question
What are the pros and cons of promises over callbacks in Javascript?
0
votes
asked
Oct 1, 2023
in
JavaScript
by
GeorgeBell
What are the pros and cons of promises over callbacks in Javascript?
javascript-interview-questions-answers
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Oct 1, 2023
by
GeorgeBell
Below are the list of pros and cons of promises over callbacks,
Pros:
It avoids callback hell which is unreadable
Easy to write sequential asynchronous code with .then()
Easy to write parallel asynchronous code with Promise.all()
Solves some of the common problems of callbacks(call the callback too late, too early, many times and swallow errors/exceptions)
Cons:
It makes little complex code
You need to load a polyfill if ES6 is not supported
...