JavaScript · Middle · Question 22 of 75
What does the chain print?
Promise.resolve(1)
.then(x => x + 1)
.then(x => { throw new Error(String(x)); })
.catch(e => e.message)
.then(x => console.log(x));- ✓Correct answer:
2 - 2
1 - 3Nothing: the chain stops at
catch
Explanation
The value returned from then is passed along. An error skips then handlers until the nearest catch, and catch returns a normal value ('2'), after which the chain continues as fulfilled.