title: Javascript and function prototype assignment
body: <p>I've always assumed that the prototype of a function was shared among all the objects, in a sense by reference. So if you change the value of a property of the prototype, all objects that share that prototype have the values change for them as well.  So for instance below it seems that instead of the property bar being shared between all objects, it is copied.  Is this right?  Are the properties of the prototype of the constructor simply copied to all the class objects as they are created, or are they shared by linkage?</p>
  
  <pre><code>function foo()
  {
       this.bar = 1;
  }
  function derived() { }
  derived.prototype = new foo()
  
  object1 = new derived()
  object2 = new derived()
  
  object1.bar = 2;
  //but notice if I had said here derived.prototype.bar = 3, object1.bar would still equal 2 but object2.bar would equal 3
  alert(object2.bar) // this prints 1;
  </code></pre>