JavaScript Promise catch()

Definition and usage

catch() The method provides a callback function.

The callback is a function that is executed when a Promise is rejected.

Example

myPromise.catch(x => myDisplay(x));

Try it yourself

Syntax

promise.catch(rejected())

Parameters

Parameters Description
rejected() Function to be executed when a Promise is rejected.

Return value

Type Description
Object New Promise object.

Browser support

catch() is a feature of ECMAScript 6 (ES6).

Since June 2017, ES6 (JavaScript 2015) has been supported in all modern browsers:

Chrome Edge Firefox Safari Opera
Chrome 51 Edge 15 Firefox 54 Safari 10 Opera 38
2016 年 5 月 2017 年 4 月 2017 年 6 月 2016 年 9 月 2016 年 6 月

catch() 不支持 Internet Explorer。