title: JavaScript: Where to put prototype function
body: <p>I wonder what is the difference between these two approaches. They both work but I don't understand if the 2nd approach might have undesirable implications?</p>
  
  <pre><code>// A. Putting a prototype method outside the function declaration (what I would normally do)
  var Cat = function(){
  }
  
  Cat.prototype.eat = function(){
      // implementation
  }
  
  // B. Putting a prototype method inside the function declaration (it works too but the scoping seems different)
  var Cat = function(){
  
      Cat.prototype.eat = function(){
          // implementation
      }   
  }
  </code></pre>