EventTarget 和 Event API


EventTarget and Event API】

EventTargetEvent 对象是 Node.js 特有的 EventTarget Web API 实现,由一些 Node.js 核心 API 提供。

【The EventTarget and Event objects are a Node.js-specific implementation of the EventTarget Web API that are exposed by some Node.js core APIs.】

const target = new EventTarget();

target.addEventListener('foo', (event) => {
  console.log('foo event happened!');
});