Skip to content

Instantly share code, notes, and snippets.

@SmolinPavel
Created May 19, 2021 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SmolinPavel/985302f0fdd6ccbfddbd2fe96eed0680 to your computer and use it in GitHub Desktop.
Save SmolinPavel/985302f0fdd6ccbfddbd2fe96eed0680 to your computer and use it in GitHub Desktop.
JS console.log quest (micro/macro task queues)
// what will be the output to the console?
console.log(1);
setTimeout(() => {
console.log(2);
setTimeout(() => console.log(3), 200);
}, 200);
new Promise(() => console.log(4));
setTimeout(() => console.log(5), 0);
Promise.resolve().then(() => console.log(6));
setTimeout(() => console.log(7), 400);
new Promise((resolve) => {
setInterval(() => resolve(8), 100);
}).then(console.log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment