title: Advantages of using prototype, vs defining methods straight in the constructor?
body: <p>I am wondering if there are any advantages of using any of these over the other, and which way should I go?</p>
  
  <p>Constructor approach:</p>
  
  <pre><code>var Class = function () {
  
      this.calc = function (a, b) {
          return a + b;
      };
  
  };
  </code></pre>
  
  <p>Prototype approach:</p>
  
  <pre><code>var Class = function () {};
  
  Class.prototype.calc = function (a, b) {
      return a + b;
  };
  </code></pre>
  
  <p>I don't like that, using the prototype, method definitions are separated from the class, and I'm not aware if there is any specific reason I should use this over just the first approach.</p>
  
  <p>Also, is there any benefit of using a function literal to define a "class", over just function definition:</p>
  
  <pre><code>var Class = function () {};
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>function Class () {};
  </code></pre>
  
  <p>Thanks!</p>