title: Intercept the fetching of properties / methods of a javascript object
body: <p>How/Can I intercept a request to get a method/property on an javascript object and return a custom value instead.</p>
  
  <p>For example,</p>
  
  <pre><code>var obj = {
      // This "get" method is where I want to replace the call to get a property of an object.
      get : function(propertyName) {
          if (propertyName == 'somePropertyThatDoesntExist') { return 1; }
          else { return 0; } // Something like this?
  };
  
  // Either this method of access,
  var myValue1 = obj.somePropertyThatDoesntExist
  var myValue2 = obj.someOtherPropertyThatDoesntExist
  
  // Alternatively, 
  var myValue3 = obj['somePropertyThatDoesntExist']
  var myValue4 = obj['someOtherPropertyThatDoesntExist']
  </code></pre>
  
  <p>So myValue1 and myValue3 will have a value of 1, and myValue2 and myValue4 will have a value of 0.</p>
  
  <p>Currently, myValue1, 2, 3, 4 would all be "undefined".</p>