Junior — Senior
Determining the order of output to the console (example 60)
livecode
Task condition
Determine the order in which messages will be printed to the console:
const run = () => {
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);
};