title: prototype.function vs this.function with a twist
body: <p>Old question, asked and answered many times, but with a bit of a twist. First the prototype version:</p>
  
  <pre><code>someA = function() {
      this.val = 'a';
  }
  someA.prototype.getVal = function() {
      return this.val;
  }
  </code></pre>
  
  <p>Now the other version:</p>
  
  <pre><code>someA = function() {
      this.val = 'a';
      this.getVal = function() {
          return this.val;
      }
  }
  </code></pre>
  
  <p>Now, let's say the getVal() function is <strong>HUGE</strong>, and you'll be creating thousands of objects of someA, but for whatever reason, you wanted to use the this.getVal version?  What if we wrote it this way:</p>
  
  <pre><code>someA =function() {
      this.val = 'a';
      this.getVal = this._getVal;
  }
  someA.prototype._getVal = function() {
      return this.val;
  }
  </code></pre>
  
  <p>Doing it this way, would you essentially have the advantages of both?</p>
  
  <p>p.s. On a completely different (but still somewhat related) topic, how does one add the questions and comments <em>inside</em> the question or one of the answers?</p>
  
  <p><strong>Edited:</strong> changed all occurances of <code>return val</code> to <code>return this.val</code> -- dumb mistake ;-)</p>