Standard built-ins

Promise.prototype.catch()

Try the free JavaScript compiler

Attaches a rejection reaction. A normal return recovers the downstream promise; throwing or returning a rejection propagates failure.

Formal Syntax & Structure

javascript syntaxjavascript
promise.catch(onRejected)

Parameters & Attributes

NameTypeDescription
onRejectedfunctionReceives the rejection reason.

Return Value

Promise

Downstream promise.

Working Example

Example Snippetjavascript
Promise.reject("failed").catch(reason => reason.length).then(console.log);
JavaScript Reference