title: How to use JavaScript EventTarget?
body: <p>I would like to create a custom event emitter in my client-side programs. I am referencing this (sparse) documentation for <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget">EventTarget</a></p>
  
  <p><strong>My implementation attempt</strong></p>
  
  <pre><code>var Emitter = function Emitter() {
    EventTarget.call(this);
  };
  
  Emitter.prototype = Object.create(EventTarget.prototype, {
    constructor: {
      value: Emitter
    }
  });
  </code></pre>
  
  <p><strong>My desired usage</strong></p>
  
  <pre><code>var e = new Emitter();
  
  e.addEventListener("hello", function() {
    console.log("hello there!");
  });
  
  e.dispatchEvent(new Event("hello"));
  // "hello there!"
  </code></pre>
  
  <p><strong>Where it fails</strong></p>
  
  <pre><code>var e = new Emitter();
  // TypeError: Illegal constructor
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <hr>
  
  <p><strong>Update</strong></p>
  
  <p>The following is possible, but it's a hack that depends on a dummy DOMElement</p>
  
  <pre><code>var fake = document.createElement("phony");
  fake.addEventListener("hello", function() { console.log("hello there!"); });
  fake.dispatchEvent(new Event("hello"));
  // "hello there!"
  </code></pre>
  
  <p>I'd like to know how to do this without having to use the dummy element</p>