title: JavaScript instance functions versus prototype functions
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/310870/use-of-prototype-vs-this-in-javascript">Use of &#39;prototype&#39; vs. &#39;this&#39; in Javascript?</a>  </p>
  </blockquote>
  
  
  
  <p>My understanding of the different kinds of JavaScript functions are as follows:</p>
  
  <pre><code>function MyObj() {
      this.propOne = true;
      this.publicInstanceFunc = function() {
          if (propOne)
              return 'public instance function';
      }
      function privateFunc() {
          return 'private function only visible inside this constructor';
      }
  }
  
  MyObj.prototype.protoFunc = function() {
      if (this.propOne)
          return 'prototype function shared amongst all instances of MyObj';
  }
  </code></pre>
  
  <ol>
  <li>Are these correct?</li>
  <li>In what cases should one put functions on the prototype (e.g. <code>protoFunc</code>) vs. in the constructor (e.g. <code>publicInstanceFunc</code>)?</li>
  <li>Is using <code>this</code> the correct way to access properties inside prototype functions?</li>
  </ol>