1.

What is promise in JavaScript with example?

Answer»

An OBJECT that shows the eventual completion or failure of asynchronous options along with its resultant value is CALLED promise in JavaScript. The possible three states of a promise are PENDING, fulfilled, or rejected. It allows handling multiple asynchronous OPERATIONS in JavaScript.

A Promise has 3 states:

  • Pending: initial state, neither fulfilled nor rejected.
  • Fulfilled: meaning that the OPERATION was completed successfully.
  • Rejected: meaning that the operation failed.


Discussion

No Comment Found