Valid JS-Dev-101 Dumps shared by EduDump.com for Helping Passing JS-Dev-101 Exam! EduDump.com now offer the newest JS-Dev-101 exam dumps, the EduDump.com JS-Dev-101 exam questions have been updated and answers have been corrected get the newest EduDump.com JS-Dev-101 dumps with Test Engine here:
Refer to the code: 01 function execute() { 02 return new Promise((resolve, reject) => reject()); 03 } 04 let promise = execute(); 05 06 promise 07 .then(() => console.log('Resolved1')) 08 .then(() => console.log('Resolved2')) 09 .then(() => console.log('Resolved3')) 10 .catch(() => console.log('Rejected')) 11 .then(() => console.log('Resolved4')); What is the result when the Promise in the execute function is rejected?
Correct Answer: D
execute() returns a Promise that immediately calls reject(). So promise starts in a rejected state. When a Promise is rejected and you chain .then() calls without rejection handlers, all those .then() callbacks are skipped until a .catch() is encountered: promise .then(...) // skipped .then(...) // skipped .then(...) // skipped .catch(...) // executed .then(...); // executed after catch Execution: .then(() => console.log('Resolved1')) is skipped. .then(() => console.log('Resolved2')) is skipped. .then(() => console.log('Resolved3')) is skipped. .catch(() => console.log('Rejected')) runs and logs Rejected. The .catch() returns a resolved Promise (no explicit return, so undefined), so the next .then() runs: .then(() => console.log('Resolved4')) logs Resolved4. Final output: Rejected Resolved4 This matches option D.