title: Confusion about when to use prototype in Crockford's example of Pseudoclassical Inheritance
body: <p>In Douglas Crockford's <em>JavaScript: The Good Parts</em>, he explains the idea of Pseudoclassical inheritance with this piece of code, which shows <code>Cat</code> inheriting from <code>Mammal</code>.</p>
  
  <pre><code>var Cat = function (name) {
          this.name = name;
          this.saying = 'meow';
  };
      // Replace Cat.prototype with a new instance of Mammal
  
      Cat.prototype = new Mammal();
  
      // Augment the new prototype with
      // purr and get_name methods.
  
      Cat.prototype.purr = function (n) {
          var i, s = '';
          for (i = 0; i &lt; n; i += 1) {
              if (s) {
                 s += '-'; 
              }
              s += 'r'; 
           }
           return s; 
      };
  
      Cat.prototype.get_name = function () { 
          return this.says() + ' ' + this.name +
                  ' ' + this.says();
      };
  
  var myCat = new Cat('Henrietta');
  var says = myCat.says(); // 'meow'
  var purr = myCat.purr(5); // 'r-r-r-r-r' var name = myCat.get_name();
  // 'meow Henrietta meow'
  </code></pre>
  
  <p>Then he introduces a new method called 'inherits' to help make the code more readable.</p>
  
  <pre><code>Function.method('inherits', function (Parent) { 
     this.prototype = new Parent();
     return this;
  });
  </code></pre>
  
  <p>He shows the example again using the new 'inherit' method.</p>
  
  <pre><code>var Cat = function (name) {
           this.name = name;
           this.saying = 'meow';
       }.
           inherits(Mammal).
           method('purr', function (n) {
               var i, s = '';
               for (i = 0; i &lt; n; i += 1) {
                   if (s) {
                       s += '-';
          }
          s += 'r'; 
      }
      return s; 
      }).
      method('get_name', function () {
          return this.says() + ' ' + this.name + ' ' + this.says();
  });
  </code></pre>
  
  <p>It looks to me like in this new example, <code>purr</code> and <code>get_name</code> are defined directly on the <code>Cat</code> object, whereas in the first example they were defined on <code>Cat.prototype</code>. Is that right? If so, why didn't he define his new methods on <code>Cat.prototype</code>? Does it make a difference?</p>