Skip to content
Onsite

Output: promise chain where a then throws, followed by catch, then another then

MediumP1Output

What does this code print?

1Promise.resolve(1)
2 .then((v) => {
3 console.log('then', v);
4 throw new Error('boom');
5 })
6 .catch((e) => {
7 console.log('catch', e.message);
8 return 'recovered';
9 })
10 .then((v) => console.log('then', v));
Saved automatically

One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).

Hints

Saved automatically