What is a Promise ?
The Promise is an object in Javascript that is use for asynchronous programming.
It has different states like,
1. Pending: A Promise is in process.
2. Fulfilled: A Promise has been completed.
3. Rejected: A promise is rejected.
Demonstration
Here is a demonstration of how promise work:
An Example of Promise.
Here is another example of promises.
Promise vs Async await.
This is most debated and is a whole topic in itself. The major difference in Promise is the use of .then which is nested and it eventually makes too make nested functions and reduces the maintainability and readability of the code.
On the other hand async await makes the code look more synchronous and readable.
At the end both aid to achieve the same task.
If you liked the blog, please do follow me.
Stay tuned for the next blog.
Thank you for reading. Happy Coding !