Skip to content
Junior–Senior164 views

Determining the order of output to the console (example 96)

Asked at

Task condition

This task requires understanding the order in which lines will be printed to the console when executing the provided JavaScript code, considering the characteristics of microtask and macrotask queues.

setTimeout(function timeout() {
    console.log("T");
}, 0);

var p = new Promise(function (resolve, reject) {
    console.log("F");
    resolve();
});

p.then(function () {
    console.log("L");
});

console.log("G");

Describe which values will appear in the console and why they are output in this specific sequence.

Frontend tasks in the code trainer