Sobes.tech
Junior — Senior

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

livecode

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.