MessageChannel
2022年5月1日小于 1 分钟
MessageChannel
Question
What does the code snippet to the right output by console.log
?
Snippet
console.log(1)
const mc = new MessageChannel()
mc.port1.onmessage = () => {
console.log(2)
}
Promise.resolve().then(() => {
console.log(3)
})
setTimeout(() => {
console.log(4)
}, 0)
console.log(5)
mc.port2.postMessage('')
console.log(6)