Skip to content

Latest commit

 

History

History
55 lines (36 loc) · 694 Bytes

62.MessageChannel.md

File metadata and controls

55 lines (36 loc) · 694 Bytes

62. MessageChannel

Problem

https://bigfrontend.dev/quiz/message-channel

Problem Description

What does the code snippet below output by console.log?

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);

Answer

1
5
6
3
2
4

Reference