Junior — Senior
Determining the order of output to the console (task 24)
livecode
Task condition
It is necessary to understand in what order the messages will be printed in the console when the function is called. Consider the following code and specify the output sequence.
const execute = () => {
setTimeout(() => {
console.log('timeOut');
}, 0);
console.log(1);
new Promise((resolve) => {
console.log('Promise');
setTimeout(() => {
console.log('777');
resolve();
}, 0);
})
.then(() => {
console.log('then1');
})
.then(() => {
console.log('then2');
});
console.log(4);
setTimeout(() => {
console.log('timeOut2');
}, 0);
};