title: javascript prototype inheritance
body: <p>This seems inconsistent, but probably is due to the fact that I'm new to javascript's prototype inheritance feature.  </p>
  
  <p>Basically, I have two base class properties, "list" and "name".  I instantiate two subclasses and give values to the properties.  When I instantiate the second subclass, it gets the list values from the first subclass instance, but only for the "list" and not for "name".  What's going on??  Of course, I would prefer that any subsequent subclass instances not get values from other instances, but if that's going to happen, it should be consistent!</p>
  
  <p>Here is a code snippet:</p>
  
  <pre><code>    function A()
      {
          this.list = [];
          this.name = "A";
      }
      function B()
      {
      }
      B.prototype = new A();
  
      var obj1 = new B();
      obj1.list.push("From obj1");
      obj1.name = "obj1";
  
      var obj2 = new B();
  
      //output:
      //Obj2 list has 1 items and name is A
      //so, the name property of A did not get replicated, but the list did
      alert("Obj2 list has " + obj2.list.length + " items and name is "+ obj2.name);    
  </code></pre>