title: Understanding Javascript's OOP: instances modifying other instances
body: <p>I'm having some trouble understanding why modifying a property in instance <code>a</code> modifies the same property on instance <code>b</code>. </p>
  
  <pre><code>var A = function (){
  
  };
  
  A.prototype.data = {
      value : 0
  };
  
  var a = new A();
  var b = new A();
  
  console.log(a.data.value, b.data.value); // 0, 0
  a.data.value = 5;
  console.log(a.data.value, b.data.value); // 5, 5
  </code></pre>
  
  <p>Shouldn't the prototype keyword make the <code>data</code> variable an instance variable ?</p>
  
  <p>This seems not to be the case in this example which executes as expected:</p>
  
  <pre><code>var B = function (){
      this.data = {
          value : 0
      };
  };
  
  var i = new B();
  var j = new B();
  
  console.log(i.data.value, j.data.value); // 0, 0
  i.data.value = 5;
  console.log(i.data.value, j.data.value); // 5, 0
  </code></pre>
  
  <p>I'm confused as why the prototype method wont work. Maybe i'm lacking some conceptual knowledge.</p>