title: Adding properties in prototype chains using DefineProperty
body: <p>I found a difference in how JavaScript adds properties to objects. Code example below shows it.</p>
  
  <pre><code>var t1 = {
      x: 1
  }
  
  var t2 = {}
  
  Object.defineProperty(t2, 'y', {
      value: 2,
      configurable: false,
      writable: false
  });
  
  Object.setPrototypeOf(t1, t2);
  
  t1.y = 100;
  t1.y; --&gt; returns 2
  Object.defineProperty(t1, 'y', { value: 100 });
  t1.y; --&gt; return 100
  </code></pre>
  
  <p>t1 has t2 as its prototype. I make sure the property 'y' added to t2 is non configurable and non writable. When I try to add y to t1 by using t1.y = 100, y is not added to the object and t1.y still return 2. However, when using defineProperty, y does get added to t1.</p>
  
  <p>I figure it has something to do with how JavaScript treats the prototype chain but i can't wrap my head around it...</p>