Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardNodeJSevent loop phasesSingle-choice MCQ

This snippet aims to show how the `check` phase relates to `setTimeout(0)`. What does it print, and why is the order between `immediate` and `timeout` deterministic *here* but not when the same two are scheduled from the main module top level?

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