Level 30

Inside I/O, immediate wins

The same two calls, but this time inside a file-read callback.

const fs = require('node:fs');fs.readFile(__filename, () => {  setTimeout(() => console.log('timeout'), 0);  setImmediate(() => console.log('immediate'));});

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…