// console.log('start');
 
// Promise.resolve().then(() => {
// console.log('promise1');
// });
 
// console.log('end');
 
// ===== 2 =====
 
// console.log('start');
 
// setTimeout(() => {
// console.log('timeout');
// }, 0);
 
// Promise.resolve().then(() => {
// console.log('promise');
// });
 
// console.log('end');
 
// ===== 3 =====
 
// Promise.resolve()
// .then(() => {
// console.log(1);
// return Promise.resolve();
// })
// .then(() => {
// console.log(2);
// });
 
// console.log(3);
 
// Цепочка промисов
 
// Promise.reject('promise failed')
// .then(data1 => {
// console.log(data1); // ?
// })
// .then(data2 => {
// console.log(data2); // ?
// })
// .then(data3 => {
// console.log(data3); // ?
// })
// .finally(() => {
// console.log('finally');
// })
// .catch(error => {
// console.log(error); // ?
// })
// .then(() => {
// console.log('after handled error'); // ?
// })
 
// ===== 4 =====
 
// Promise.resolve()
// .then(() => {
// console.log('A');
// return Promise.reject('Error');
// })
// .then(() => {
// console.log('B');
// })
// .catch(() => {
// console.log('C');
// })
// .then(() => {
// console.log('D');
// });
 
// ===== 5 =====
 
console.log('start');
 
async function test() {
console.log('inside');
await '12345';
console.log('after await');
}
 
test();
 
console.log('end');
 
Click Run to execute JavaScript.
Code runs in an isolated environment.