Level 37

Cutting in line

One listener added with on, then one with prependListener.

const { EventEmitter } = require('node:events');const bus = new EventEmitter();bus.on('go', () => console.log('first added'));bus.prependListener('go', () => console.log('prepended'));bus.emit('go');

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…