Async Functions - Promises Flashcards

1
Q

What is a promise

A

A Promise is a proxy for a value not necessarily known when the promise is created. It allows you to associate handlers with an asynchronous action’s eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point in the future.

A Promise is in one of these states:

pending: initial state, neither fulfilled nor rejected.
fulfilled: meaning that the operation was completed successfully.
rejected: meaning that the operation failed.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/promises.png

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

What are the three states of a promise

A

pending: initial state, neither fulfilled nor rejected.
fulfilled: meaning that the operation was completed successfully.
rejected: meaning that the operation failed.

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

list the promise methods

A

promise. then() , promise.catch()

promise. finally()

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