InterviewSolution
| 1. |
What are promises in JavaScript? |
|
Answer» A promise in JavaScript represents the eventual completion or failure of an asynchronous operation and its resulting value. It is a PROXY for a value that might not necessarily be known when the promise object is CREATED. Promises are used in Asynchronous methods, where instead of immediately returning a value, the method returns a promise to provide a value at some POINT in the future. To put it simply, promises are a way to return synchronous values from an asynchronous method. The value for which the promise acts as a proxy, can either be a resolved value, or a reason that it was rejected. A promise can be in either of the three states:
A promise is considered to be SETTLED if it is either in the fulfilled state or in the rejected state. |
|