Sobes.tech
Back to tasks
Junior — Senior
24

Определение последовательности вывода в консоль

Get help with live coding in real time with Sobes Copilot
Task condition

Нужно выяснить, в каком порядке будут напечатаны значения в консоль, учитывая синхронные вызовы, микрозадачи (Promise.then, .catch) и макрозадачи (setTimeout).

console.log(1);

setTimeout(() => console.log(2));

Promise.reject(3)
  .catch(console.log)
  .then(() => console.log(7));

new Promise(resolve => setTimeout(resolve))
  .then(() => console.log(4));

Promise.resolve(5)
  .then(console.log)
  .then(() => console.log(8));

console.log(6);