bit confused with this description of the macrotask and the microtask queue.
For each loop of the ‘event loop’ one macrotask is completed out of the macrotask queue. After that macrotask is complete, the event loop visits the microtask queue. The entire microtask queue is completed before moving on.
setTimeout(function() {
console.log('macrotask');
}, 0);
Promise.resolve().then(function() {
console.log('microtask 1');
}).then(function() {
console.log('microtask 2');
});
Shouldn't this code output 'macrotask' first? as setTimeout is part of the macrotask queue that is completed before the loop goes to the microtask queue?
