What is the CustomEvent class in Deno?

What is Deno?

It is a small, general-purpose runtime environment for JavaScript with first-class support for various interfaces, ECMAScript modules, and seamless TypeScript integration.

CustomEvent class

This class returns any custom data used to create the event. Typically, it is used for synthetic events. It has two main features, constructors and properties.

class CustomEvent<T = any> extends Event

Constructors

constructor(typeArg: string, eventInitDict?: CustomEventInit<T>)

Properties

readonly detail: T
// This refers to data event returned. 
// It is typically used for synthetic events. 
// T refers to the data type of the custom event passed in the constructor. 

Syntax

interface CustomEventInit<T = any> extends EventInit {
  detail?: T;
}

declare class CustomEvent<T = any> extends Event {
  constructor(typeArg: string, eventInitDict?: CustomEventInit<T>);
  // Returns any custom data event was created with.

// Typically used for synthetic events. 
  readonly detail: T;

}

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved