title: Default Function/Value for JavaScript Class
body: <p>Is it possible to set something of a default/fallback function for a JavaScript class?</p>
  
  <pre><code>var a = new function() {
  
    this.b = function() {
      return "B";
    }
  
    return "A";
  }
  </code></pre>
  
  <p>In this example, I'd want to see <code>B</code> when executing <code>alert(a.b())</code>, and <code>A</code> for <code>alert(a)</code> alone.</p>