How do you create a promise in JavaScript?
Use new Promise((resolve, reject) => { ... }). The executor function runs immediately. Call resolve(value) to fulfill the promise, or reject(reason) to reject it. The executor usually starts an async operation.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in What Are Promises in JavaScript?
An object representing the eventual result of an async operation. It is a placeholder for a future value. A promise has three states: pending, fulfilled, and rejected. It settles (fulfills or rejects) exactly once.
Pending (initial, not yet settled), fulfilled (operation succeeded, has a value), and rejected (operation failed, has a reason/error). A promise transitions from pending to fulfilled or rejected once and cannot change state after settling.
Promises guarantee once-only settlement (no inversion of control), enable flat chaining with .then, use a single .catch for all errors, provide Promise.all for parallel operations, and enable async/await for synchronous-looking code.
Still have questions?
Browse all our FAQs or reach out to our support team
