Skip to content
IT glossary
ProgrammingUpdated December 3, 2026

Promise

In JavaScript, a promise is an object that represents the eventual outcome of an operation. It lets you use the result when it becomes available or handle the reason the operation failed.

Also known as: промис

A result you don't have yet

When you call an API to read a file or make a network request, the result may not be ready when the call returns. A promise gives you something to work with immediately: you can pass it to another function, wait for it with await, or attach handlers with .then() and .catch(). The promise represents the outcome; it isn't the file contents or the network response itself.

From one step to the next

A promise starts out pending. It can become fulfilled with a value or rejected with a reason. Once it's fulfilled or rejected, it's settled, and that outcome cannot change. You can still attach handlers after it settles. They run as microtasks, after the current synchronous code finishes, rather than during the call to .then().

Every .then() call returns a new promise. Returning a value from the handler fulfills the new promise with that value. Returning a promise makes the new promise follow its outcome. Throwing an error rejects the new promise. A .catch() further down the chain can handle that rejection and, if appropriate, return a fallback value so the remaining steps can continue.

Example: reading a settings file

import { readFile } from 'node:fs/promises';

readFile('settings.json', 'utf8')
  .then(text => JSON.parse(text))
  .then(settings => console.log(settings.theme))
  .catch(error => console.error(error.message));

In Node.js, readFile returns a promise for the file contents. JSON.parse() is synchronous, but because it runs inside a .then() handler, an exception it throws becomes a rejection. The same .catch() therefore handles both a file read failure and invalid JSON. If you rewrite the chain using await, use try/catch around the awaited read and the parse to handle both failures.

Combining work without confusing it with threads

If two operations don't depend on each other's results, you can start both and pass their promises to Promise.all(). It fulfills when all the inputs fulfill, with values in input order. If an input rejects, the combined promise rejects without waiting for the others; it doesn't cancel them. Use Promise.allSettled() when you need to report each outcome, including failures.

Promises don't move CPU-heavy work to another thread. Even the executor function you pass to new Promise(...) runs synchronously. And while await suspends the rest of the current async function until it can resume, it doesn't block unrelated JavaScript from running.

In interviews

Expect to trace a short chain or explain why a rejection wasn't caught. Look at what each handler returns: calling a promise-returning function without returning or awaiting its promise can leave that work outside the chain. This can let the next step run too early and leave the rejection unhandled.