A JavaScript Promise represents one eventual value. It gives asynchronous work a consistent interface whether data is nearby or remote, replacing nested callbacks with chains that read from one step to the next. A promise ultimately fulfills with a value or rejects with an error. section 8.2 section 8.2.1 section 8.2.2
Create and consume a promise
const result = new Promise((resolve, reject) => { const value = doWork(); if (value === null) reject(new Error('No value')); else resolve(value); }); result.then(useValue).catch(handleError); The constructor receives an executor, which starts when the promise is created—not when a handler is attached. The promise begins pending; resolving or rejecting settles it. section 8.2 section 8.2.2 section 8.6
Each then step returns another Promise, so sequential operations can stay flat. A step may return a plain value or another Promise; then flattens the latter automatically. Fulfillment carries the result forward, while catch handles rejection. This resembles mapping and chaining operations on algebraic data types, without requiring callers to manage each callback’s timing. section 1.5 section 8.2.2
A file-processing chain
A file workflow can check access, read the file with fs.promises, decode and tokenize its contents, count the resulting entries, then catch an error to report a missing file or insufficient permissions. Each operation has a distinct place in the chain rather than another level of callback nesting. section 8.2.4 section 8.2
Promises fit single asynchronous results. async/await expresses the same underlying behavior as a sequence of statements, while async generators address sequences delivered over time. Promises also have limits: their executors are not lazy, and there is no standard way to cancel a running promise. section 1.5 section 8.6
Figure 1.10 How Promise objects chain to form new Promise objects. Along the way, the same pattern repeats. Both success and rejection cases lead to a new Promise object returned.
Follow how each link in a chain creates a new Promise, including paths for fulfillment and rejection. section 1.5






