JS: Promise .prototype .catch

By Xah Lee. Date: . Last updated: .

Promise .prototype .catch

(new in ECMAScript 2015)

promise_object.catch(onRejected)

equivalent to

promise_object.then( undefined, onRejected)

What's the difference between p.then(aa, bb) vs p.then(aa).catch(cc)

bb (the second argument of .then) only sees a rejection of p itself.

If aa throws, or returns a rejected promise, bb does not run. That rejection goes to whatever comes after this .then.

.catch sits after aa, so it sees: