Problem

In what order will the logs below show up in the console?

console.log('First')

setTimeout(() => {
  console.log('Second')
}, 0)

new Promise((res) => {
  res('Third')
}).then(console.log)

console.log('Fourth')
Solution

In what order will the logs below show up in the console?

console.log('First')

setTimeout(() => {
  console.log('Second')
}, 0)

new Promise((res) => {
  res('Third')
}).then(console.log)

console.log('Fourth')

First, Fourth, Third, Second.