Promises Javascript
- The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
- 3 Promise states:
pending: initial state, neither fulfilled nor rejectedfulfilled: meaning that the operation was completed successfully.rejected: meaning that the operation failed.
- Promises are meant to replace callbacks
Why do we use it, what are its advantages?
- Prevents Callback Hell Javascript
- Pyramid of doom (code doesn't span horizontally)
- Promise Chaining Javascript