Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Event — the event object

Event represents an event. Its properties describe the event's type, target, and creation time.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

new Event(type, { bubbles: false, cancelable: false, composed: false })

Event is a Web API interface from the DOM Standard, not ECMAScript. Its constructor accepts a type; bubbles, cancelable, and composed default to false.

Event.type is the event name. Event.target is its target, initially null; Shadow DOM can retarget it. currentTarget identifies the object currently handling the listener.

Event.timeStamp describes creation time in milliseconds relative to the environment's time origin, not the Unix epoch. Precision may be reduced. These three properties are read-only.

Examples

const target = new EventTarget();
const event = new Event("ready");
console.log(event.target === null);
target.addEventListener("ready", (e) => {
  console.log(e.type);
  console.log(e.target === target);
  console.log(Number.isFinite(e.timeStamp));
});
target.dispatchEvent(event);

Result

true
ready
true
true

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources