Junior — Senior
Order of message output to the console in JavaScript (example 101)
livecode
Task condition
Determine the order in which the logs will appear in the console when executing the code below, and explain why this order occurs.
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);