Hi, my question is :
I want to know what is happening under the hood when we use a promise in our code & what is the benefit of using promises ?
Thank you in advance
Hi, my question is :
A promise is an object that may produce a single value some time in the future: either a resolved value, or a reason that it’s not resolved (e.g., a network error occurred). A promise may be in one of 3 possible states: fulfilled, rejected, or pending. Promise users can attach callbacks to handle the fulfilled value or the reason for rejection
Thank you, appreciated
Not need it to thank me😀
Promise is designed to resolve callback hell and reverse controll. In front-end develop, the promise is not used quite often. It always packaged already in some library (like, axios). Unless you are a backend developer using node or an Animation web developer. Learning the concept may be more important.
Check this https://www.youtube.com/watch?v=KpGmW_P5Ygg
I think It demostrated the mechanism of asynchronization really well.
I will always support you! It really means a lot to me word unscrambler
A promise is exactly like its plain meaning. You get a promise from your PM that he will do something in the future. You have received it already. The promise acts as a container of his future deliverable result. Your PM might deliver the result, forfeit it, or still in the process of getting it. You will have to wait some time to know. But for now, you have your PM’s promise or a word given to you.
This question might be old, but allow me to explain.
A promise is just another way to get the result of an asynchronous operation sometime in the future. It is a simple object based on the callback approach, but created to replace callbacks because of the callback hell problem.
Throughout its life a promise may be of three states:
- Pending : The operation is yet to return a response.
- Resolved : The operation returned a result and was successful.
- Rejected : The operation failed and did not return a result.
Hope this helps
There are 3 states of the Promise object:
Pending: Initial State, before the Promise succeeds or fails
Resolved: Completed Promise
Rejected: Failed Promise