The RTCDataChannelEvent() constructor creates a new RTCDataChannelEvent object.
Note: You will rarely if ever construct an RTCDataChannelEvent by hand; these events are normally created and sent by the WebRTC layer itself.
new RTCDataChannelEvent(type, options)typeA string with the name of the event. It is case-sensitive and browsers always set it to datachannel.
optionsAn object that, in addition of the properties defined in Event(), can have the following properties:
channelA RTCDataChannel, representing the data channel being associated with the event.
A new RTCDataChannelEvent object configured as specified.
In this example, a new datachannel event is created. dc is a data channel which already exists.
const event = new RTCDataChannelEvent("datachannel", { channel: dc });