EventTarget() 생성자는 새로운 EventTarget 객체 인스턴스를 만듭니다.

Syntax

var myEventTarget = new EventTarget();

Parameters

None.

Return value

EventTarget 객체의 인스턴스를 반환합니다.

Examples

class MyEventTarget extends EventTarget {
  constructor(mySecret) {
    super();
    this._secret = mySecret;
  }

  get secret() { return this._secret; }
};

let myEventTarget = new MyEventTarget(5);
let value = myEventTarget.secret;  // == 5
myEventTarget.addEventListener("foo", function(e) {
  this._secret = e.detail;
});

let event = new CustomEvent("foo", { detail: 7 });
myEventTarget.dispatchEvent(event);
let newValue = myEventTarget.secret; // == 7

Specifications

Specification Status Comment
DOM
The definition of 'EventTarget() constructor' in that specification.
Living Standard  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung Internet
Basic supportChrome Full support 64Edge ? Firefox Full support 59IE No support NoOpera Full support 51Safari No support NoWebView Android Full support 64Chrome Android Full support 64Edge Mobile ? Firefox Android Full support 59Opera Android Full support 51Safari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also

문서 태그 및 공헌자

이 페이지의 공헌자: DeadIntegral
최종 변경자: DeadIntegral,