JavaScript Execution Order: Start, End, Timeout, Promises

Quick JS Brain Teaser: What will be the output of this code? console.log('Start'); setTimeout(() => { console.log('Timeout'); }, 0); Promise.resolve() .then(() => console.log('Promise 1')) .then(() => console.log('Promise 2')); console.log('End'); Options: A) Start → End → Timeout → Promise 1 → Promise 2 B) Start → End → Promise 1 → Promise 2 → Timeout C) Start → Promise 1 → Promise 2 → End → Timeout D) Start → Timeout → Promise 1 → Promise 2 → End What's your answer? #JavaScript #JavaScriptInterviewQuestion #JavaScriptFundamentals

B) Start → End → Promise 1 → Promise 2 → Timeout

See more comments

To view or add a comment, sign in

Explore content categories