Skip to content
Onsite

Output: sync logs mixed with setTimeout, promise chains and async/await

MediumP1Output

What does this code print?

1console.log('1');
2setTimeout(() => console.log('2'), 0);
3Promise.resolve().then(() => console.log('3'));
4(async () => {
5 console.log('4');
6 await null;
7 console.log('5');
8})();
9Promise.resolve().then(() => console.log('6'));
10console.log('7');
Saved automatically

One line per console.log. Arrays as [1, 2, 3], objects as { a: 1 }, an uncaught error as Uncaught TypeError: message (Chrome and Node wording).

Hints

Saved automatically