es6-promises Flashcards
What are the three states a Promise can be in?
Pending: The initial state of a Promise, representing that the operation has not yet completed.
Fulfilled: The state of a Promise representing that the operation has completed successfully and the Promise has a returned value.
Rejected: The state of a Promise representing that the operation has failed and the Promise has a thrown error or rejected value.
How do you handle the fulfillment of a Promise?
.then() method. The .then() method takes two arguments: a callback function to handle the fulfillment (also known as the success) and a callback function to handle the rejection (also known as the failure).
How do you handle the rejection of a Promise?
the .catch() method or the second argument of the .then() method.