We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

Questa traduzione è incompleta. Collabora alla traduzione di questo articolo dall’originale in lingua inglese.

This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.

Il metodo catch() restituisce una Promise e si occusa esclusivamente nei casi respinti. Si comporta come una chiamata Promise.prototype.then(undefined, onRejected).




p.catch(function(reason) {
   // rejection


Una Function chiamata quando la Promise viene respinta. Questa funzione richiede un parametro, la motivazione della respinta.


Il metodo catch può essere utile per gestire errori nella composizione delle promise.


Uso del metodo catch

var p1 = new Promise(function(resolve, reject) {

p1.then(function(value) {
  console.log(value); // "Success!"
  throw "oh, no!";
}).catch(function(e) {
  console.log(e); // "oh, no!"


Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Promise.prototype.catch' in that specification.
Standard Initial definition in an ECMA standard.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 32 29.0 (29.0) [1] No support 19 7.1
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support No support 29.0 (29.0) [1] No support No support 8 32

[1] Gecko 24 has an experimental implementation of Promise, under the initial name of Future. It got renamed to its final name in Gecko 25, but disabled by default behind the flag dom.promise.enabled. Bug 918806 enabled Promises by default in Gecko 29.

See also

Tag del documento e collaboratori

 Hanno collaborato alla realizzazione di questa pagina: lysz210
 Ultima modifica di: lysz210,