It's funny you should ask, I was just reading the MDN Docs about this yesterday. They explain the whole concept of Promises really well. Their explanation of what promises give you vs. callbacks is a good one:
Unlike old-style passed-in callbacks, a promise comes with some guarantees:
• Callbacks will never be called before the completion of the current run of the JavaScript event loop.
• Callbacks added with .then even after the success or failure of the asynchronous operation, will be called, as above.
• Multiple callbacks may be added by calling .then several times, to be executed independently in insertion order.
But the most immediate benefit of promises is chaining.
Basically promises are much more composable + predictable than callbacks, but I heartily recommend reading through the whole article to get a better overall idea.
It's funny you should ask, I was just reading the MDN Docs about this yesterday. They explain the whole concept of Promises really well. Their explanation of what promises give you vs. callbacks is a good one:
Basically promises are much more composable + predictable than callbacks, but I heartily recommend reading through the whole article to get a better overall idea.
Thank you Donald.i am going through the MDN article.