Skip to content
Junior–Senior166 views

Determining the output sequence in the console №64

Task condition

Specify the order in which messages will appear in the console when executing the following JavaScript code:

console.log(1);

setTimeout(function() {
    console.log(2);
});

Promise.resolve(3).then(console.log);

console.log(4);

setTimeout(function() {
    console.log(5);
}, 0);

console.log(6);

const foo1 = {} => {
    console.log('foo1');

    return Promise.resolve().then(foo1);
}

foo1(); 
Frontend tasks in the code trainer