Synechron Interview Question

what are three important states in JavaScript promise?

Interview Answer

Anonymous

Mar 8, 2024

Pending: The initial state of a promise. This means that the promise's outcome hasn't been determined yet. It's in the process of executing and hasn't resolved to a value or been rejected with an error. Fulfilled (Resolved): This state indicates that the promise has completed successfully. It means that the operation associated with the promise has been completed, and the promise now has a resolved value. Once a promise is fulfilled, it stays in this state permanently. Rejected: This state indicates that the promise has been rejected due to some error or failure in the asynchronous operation. When a promise is rejected, it means that the associated operation couldn't be completed successfully, and an error reason is provided. Once a promise is rejected, it stays in this state permanently.