JSFiddle - React, Tailwind, and code Playground
by msfrisbie
JavaScript
let p1 = Promise.reject('foo');
// No handler function acts as a passthrough
let p2 = p1.catch();
console.log(p2); // Promise <resolved>: foo
// These are equivalent
let p3 = p1.catch(() => undefined);
let p4 = p1.catch(() => {});
let p5 = p1.catch(() => Promise.resolve());
console.log(p3); // Promise <resolved>: undefined
console.log(p4); // Promise <resolved>: undefined
console.log(p5); // Promise <resolved>: undefined
// These are equivalent
let p6 = p1.catch(() => 'bar');
let p7 = p1.catch(() => Promise.reject('bar'));
console.log(p6); // Promise <resolved>: bar
console.log(p7); // Promise <resolved>: bar
let p8 = p1.catch(() => new Promise(() => {}));
console.log(p8); // Promise <pending>