🚨 JavaScript Async Interview Question What will be the output? console.log("Start"); setTimeout(() => { console.log("Timeout 1"); }, 0); Promise.resolve() .then(() => { console.log("Promise 1"); }) .then(() => { console.log("Promise 2"); }); setTimeout(() => { console.log("Timeout 2"); }, 0); console.log("End"); Looks simple… But many developers get the order wrong. Because JavaScript doesn’t execute async code the way we intuitively expect. This question tests your understanding of: • Call Stack • Microtask Queue • Macrotask Queue • JavaScript Event Loop What do you think the output will be? #JavaScript #FrontendInterview #EventLoop #ReactJS #FrontendDeveloper #ProductBasedCompany
This is overrated
Start -> end --> promise1-> promise 2 -> timeout 1 -> timeout 2 this is what I think because promise will be in the micro task queue which will prioritize over callback queue/ macro task queue which holds set timeout