Назад к задачамПолучайте помощь с лайвкодингом в реальном времени с Sobes Copilot
Junior — Senior
25
Что будет напечатано в консоли? (пример 32)
Условие задачи
Определите порядок вывода сообщений в консоль при выполнении приведённого кода.
import './style.css';
document.getElementById('app').innerHTML = '\
<h1>Async Puzzle</h1>\
';
const asyncFuncA = async () => {
console.log('1', '?');
setTimeout(() => console.log('2', '?'), 0);
Promise.resolve().then(() => console.log('3', '?'));
const asyncFuncB = async () => {
setTimeout(() => console.log('4', '?'), 1);
console.log('5', '?');
Promise.resolve().then(() =>
setTimeout(() => console.log('6', '?'), 0)
);
};
const initPromise = new Promise((res) => {
console.log('7', '?');
[
Promise.resolve().then(() => console.log('8', '?')),
setTimeout(() => {
res();
},
)
];
});
await initPromise;
console.log('9', '?');
};
Promise.resolve().then(() => console.log('10', '?'));
await asyncFuncB();
console.log('11', '?');
};
asyncFuncA();
console.log('12', '?');