CKTIS / JavaScript
CustomEvent.detail — custom event data
CustomEvent.detail exposes data supplied when an event is constructed. It defaults to null; objects are passed without cloning.
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
const event = new CustomEvent(type, { detail: value });
event.detailCustomEvent.detail is an instance property of CustomEvent containing data set through the constructor's detail option. If detail is omitted or explicitly set to undefined, Web IDL applies the default value null, so event.detail === null.
The property is read-only, but it does not freeze the stored object. The object is not cloned: changing event.detail.count modifies the same object passed to the constructor.
A listener reads the data through event.detail. The example demonstrates the shared reference and default null. This is a DOM interface, not an ECMAScript language feature; Node 24 in a repository does not establish browser support.
Examples
const target = new EventTarget();
const payload = { count: 1 };
target.addEventListener("count-change", (event) => {
console.log(event.detail === payload);
event.detail.count += 1;
});
target.dispatchEvent(new CustomEvent("count-change", { detail: payload }));
console.log(payload.count);
console.log(new CustomEvent("empty").detail);Result
true 2 null
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.