title: Can you add functions to Javascript classes with the prototype keyword?
body: <p>I need to be able to add many functions to a Javascript class and I thought that you could do that with the className.prototype = function(){} but maybe I was not correct on this.</p>
  
  <pre><code>  Car.prototype.toAnotherString = function () {
      return this.model + " has done " + this.miles + " miles";
    };
  </code></pre>
  
  <p><strong>Question: Ist he prototype declared correctly in this class and can the class Car be declared some how with out the function name></strong></p>
  
  <pre><code>function Car( model, year, miles ) {
  
    this.model = model;
    this.year = year;
    this.miles = miles;
  
    this.toString = function () {
      return this.model + " has done " + this.miles + " miles";
    };
  
    Car.prototype.toAnotherString = function () {
      return this.model + " has done " + this.miles + " miles";
    };
  }
  
  var civic = new Car( "Honda Civic", 2009, 20000 );
  var mondeo = new Car( "Ford Mondeo", 2010, 5000 );
  
  console.log( civic.toString() );
  console.log( mondeo.toString() );
  console.log( civic.toAnotherString() );
  console.log( mondeo.toAnotherString() );
  </code></pre>
  
  <p>New Code:</p>
  
  <p>So is this how the prototype should be added.</p>
  
  <pre><code>function Car( model, year, miles ) {
  
    this.model = model;
    this.year = year;
    this.miles = miles;
  
    this.toString = function () {
      return this.model + " has done " + this.miles + " miles";
    };
  }
  
   Car.prototype.toAnotherString = function () {
      return this.model + " has done " + this.miles + " miles";
   };
  </code></pre>