I was reading about micro and macro tasks in the JavaScript stack. I wrote this code:
Promise.resolve().then(function () {
setTimeout(function () {
console.log('from promise one');
}, 0);
}).then(() => {
console.log('from promise two');
});
setTimeout(function () {
console.log('from timeout');
}, 0);
But I realized that from timeout shows faster than from promise one in the console...
As I understood, Promise. then() is a microtask and executes before macro task which from timeout is a microtask here... but why does execute the timeout first then Promise. then?