Sobes.tech
Junior — Senior

Determining the output sequence in console.log (example 66)

livecode

Task condition

Determine the order in which the lines will be printed to the console.

console.log('1');
setTimeout(() => {
    console.log('2');
});

new Promise((res, rej) => {
    console.log('3');
    res();
}).then(() => {
    console.log('4');
});

Promise.resolve().then(() => {
    console.log('5');
}).then(() => {
    console.log('6');
});

Promise.resolve().then(() => {
    console.log('7');
}).then(() => {
    console.log('8');
});