Standard built-ins
Promise.prototype.then()
Attaches reactions and returns a downstream promise. Returned values fulfill it, thrown exceptions reject it, and returned thenables are followed.
Formal Syntax & Structure
javascript syntaxjavascript
promise.then(onFulfilled, onRejected)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| onFulfilled | function | Receives the fulfillment value. |
| onRejected | function | Receives the rejection reason. |
Return Value
Promise
Represents the reaction outcome.
Working Example
Example Snippetjavascript
Promise.resolve(3).then(n => n * 2).then(n => n + 1).then(console.log);