promises Flashcards
1
Q
What are the three states a Promise can be in?
A
pending: initial state, neither fulfilled nor rejected.
fulfilled: meaning that the operation was completed successfully.
rejected: meaning that the operation failed.
2
Q
How do you handle the fulfillment of a Promise?
A
The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise.
3
Q
How do you handle the rejection of a Promise?
A
The catch() method returns a Promise and deals with rejected cases only.