Process Lifecycle · Level 5 of 8

exitCode lets the work finish

The script sets process.exitCode = 2 and still has a timer booked.

process.on('exit', (code) => {  console.log('exit code ' + code);  process.exitCode = 0; // reset so this demo exits cleanly});process.exitCode = 2;setTimeout(() => console.log('timer still runs'), 10);console.log('main done');

1. Predict the output

Tap the lines in the order you think they print.

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