Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What does the following log? console.log(1); setTimeout(()=>console.log(2),0); Promise.resolve().then(()=>console.log(3)); console.log(4);

  1. A 1 2 3 4
  2. B 1 4 3 2
  3. C 1 4 2 3
  4. D 1 3 4 2
Answer

1 4 3 2

Synchronous code runs first (1, 4), then the microtask queue drains completely (3), then one macrotask runs (2).

All Javascript MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as