title: Object Prototype: Case Insensitive Getter On All Properties
body: <p>I am trying to make an <code>Object</code> who, when I search for a property, performs a "look-up" of that property case-insensitively.</p>
  
  <pre><code>var x = new CaseInsensitiveObject();
  
  x.firstProperty = "Hello!";
  
  alert(x.firstproperty); //alerts Hello!
  </code></pre>
  
  <p>I've tried using <code>Object.defineProperty()</code> for this, yet it requires the string literal for the property as a parameter <em>(<code>Object.defineProperties()</code> will have the same problem if you think about it)</em>.</p>
  
  <p>Is there a way that I can generic set the <code>getter</code> for all object properties of an object without providing the key name? i.e:</p>
  
  <pre><code>Object.defineAllProperties(obj, {
      get: function(prop)
      {
          if(!prop.toLowerCase &amp;&amp; prop.toString)
              prop = prop.toString();
          if(prop.toLowerCase)
              prop = prop.toLowerCase();
          return this[prop];
      }
  });
  </code></pre>
  
  <p>If not all properties, how could I set <strong>even one property</strong> of an <code>Object</code> to be case insensitive?!</p>
  
  <p><strong>NOTE:</strong></p>
  
  <p>I understand that extending the <code>Object.prototype</code> is generally a bad thing to do, but I have my reasons. I need a quick fix due to some database changes. The eventual fix will take days to do, and I need running software for QA to test against until then. This prototype method will make everything work while I make all of the necessary changes, and this method WILL NOT be put into any production environment. So, if you plan on shooting me down and yelling at me for even thinking about doing this, I'm not listening.</p>
  
  <p>Thanks everybody!</p>