Creating events in JavaScript like C#
<p>I primarily write code in C#. However, I'm working with some JavaScript. I have defined a class in JavaScript as shown here:</p>

<pre><code>function Item(id, name) {
    this.ID = id;
    this.Name = name;

    // define event submitCompleted
    this.submit = function() {
      // When the submission is completed, fire "submitCompleted" event.
    };
}
</code></pre>

<p>My challenge is, I don't know how to create and fire custom events in JavaScript. If this was C#, I'd do the following:</p>

<pre><code>public class Item
{
  public string ID { get; set; }
  public string Name { get; set; }

  public Item(string id, string name)
  {
    this.ID = id;
    this.Name = name;
  }

  public event EventHandler SubmitCompleted;
  public void Submit() 
  {
    // Submission logic
    SubmitCompleted(this, EventArgs.Empty);
  }
}
</code></pre>

<p>How do I do the equivalent in JavaScript? Thank you!</p>
