A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-28.js
1try{
2awaitPromise.reject(newError('fail'));
3}catch(e){
4console.log(e.message);
5}
6console.log('after');
Async
Answer & explanation
Console output
fail
after
Why
When you await a rejected promise, the rejection is turned into a thrown exception at the await point, which a surrounding try/catch can handle. The catch block logs "fail", and because the error was handled, normal execution resumes and "after" prints next.