AceDevHub
Beginner JavaScript Interview QuestionsBeginnerConcept

JavaScript · Question 28

What is a Promise in JavaScript, and what are its states?

Direct answer

A Promise represents the eventual completion or failure of an asynchronous result and is pending before becoming fulfilled or rejected.

A Promise starts in the pending state and later becomes either fulfilled with a value or rejected with a reason. Once settled, that state does not change.

  • then() registers fulfillment handling and can also receive a rejection handler.
  • catch() is commonly used for rejection handling.
  • finally() runs cleanup-style logic after settlement regardless of success or failure.

Promise chaining works because then() returns a new Promise. Returning a normal value feeds the next step; returning a Promise makes the chain wait for it; throwing causes the next rejection path.