Games Node.js Loop Quest Round the loop
Inside I/O: the full lineup
A file-read callback queues a timer, an immediate, a promise and a nextTick.
const fs = require('node:fs');fs.readFile(__filename, () => { setTimeout(() => console.log('timeout'), 0); setImmediate(() => console.log('immediate')); Promise.resolve().then(() => console.log('promise')); process.nextTick(() => console.log('tick'));});1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…
- 4…