title: (Javascript) Override object built-in or inherited properties?
body: <p>Working with Javascript object, <strong>which of these</strong> property overrides are valid and <strong>should work in any browser</strong>?</p>
  
  <pre class="lang-js prettyprint-override"><code>// Dot notation overrides
  var obj1 = {};
  obj1.hasOwnProperty = 123;
  obj1.constructor = 'Oh! I am not a constructor';
  
  console.log(obj1.hasOwnProperty); // 123
  console.log(obj1.constructor);    // =&gt; 'Oh! I am not a constructor'
  
  // Braces notation overrides
  var obj2 = {};
  obj2['hasOwnProperty'] = 123;
  obj2['constructor'] = 'Oh! I am not a constructor';
  
  console.log(obj2['hasOwnProperty']); // 123
  console.log(obj2['constructor']);    // =&gt; 'Oh! I am not a constructor'
  </code></pre>
  
  <p>In both Firefox and Chrome all of these work, but is it normal? Could I safely rely on this?</p>
  
  <p>If yes, is there any object properties that couldn't be overriden that way?</p>
  
  <p>P.S. I'm not speaking of "it is not safe to override <code>hasOwnProperty</code>, because someone could call <code>hasOwnProperty</code> of your object". 
  I'm just speaking of whether <strong>should those overrides just work</strong>.</p>