es6-promises Flashcards

1
Q

What are the three states a Promise can be in?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you handle the fulfillment of a Promise?

A

.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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you handle the rejection of a Promise?

A

the .catch() method or the second argument of the .then() method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly