console.log('1');
Promise.resolve()
.then(() => console.log('2')) // 1
.then(() => console.log('3')) //4
.then(() => console.log('13')) //6
.finally(() => console.log('4')) //8
.then(() => console.log(14)); // 10
queueMicrotask(() => console.log(5)); // 2
Promise.reject()
.then(() => console.log('8')) // 3
.catch(() => console.log(9)) // 5
.then(() => console.log('10')) // 7
.finally(() => console.log('11')); // 9
console.log('12');
Click Run to execute JavaScript.
Code runs in an isolated environment.
Code runs in an isolated environment.