Level 28

Between two timers

A timer queues a promise and a nextTick. Another timer is due too.

setTimeout(() => {  console.log('timer 1');  Promise.resolve().then(() => console.log('promise'));  process.nextTick(() => console.log('tick'));}, 0);setTimeout(() => console.log('timer 2'), 0);

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…
  4. 4…