Standard built-ins

Promise.prototype.then()

Try the free JavaScript compiler

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

NameTypeDescription
onFulfilledfunctionReceives the fulfillment value.
onRejectedfunctionReceives 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);
JavaScript Reference