title: How do I trap arguments to a target method when using a Proxy object?
body: <p>I'm trying to use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy" rel="noreferrer">Javascript <code>Proxy</code> objects</a> to trap the arguments that are passed to a 'method' of the target that I'm proxying.</p>
  
  <p>Please consider this example:</p>
  
  <pre><code>var test = {
      doSomething: function() {
          console.log( arguments.length );
      }
  };
  
  var testProxy = new Proxy( test, {
      get: function( target, property, receiver ) {
  
          // I'd like to have access to any arguments when
          // the property being accessed here is a function
          // that is being called
  
          return target[ property ];
      }
  } );
  
  testProxy.doSomething( 'this', 'is', 'lame' ); // I want to trap those arguments
  </code></pre>
  
  <p>It appears that these <code>Proxy</code> objects only allow you to trap accessing the property, but not the actual function call, with its arguments, when the property is in fact a function.</p>
  
  <p>After reflecting a bit on the matter, I "get" (pardon the pun) that the <code>get</code> method is just intended for property access, in stead of invocation, but then I would have expected to be able to define something like a <code>call</code> method in the <code>Proxy</code> as well.</p>
  
  <p>Perhaps it's doable with defining an <code>apply</code> method in the <code>Proxy</code>, but then I'd probably have to create a <code>Proxy</code> object for each individual method of the object I want to proxy; and that's not what I am after.</p>
  
  <p>Unless I'm overlooking an actual alternative possibility here: how is it that this is overlooked in the <code>Proxy</code> implementation?! Isn't the whole point of a proxy to be able to intercept method calls and their arguments as well?</p>
  
  <p>Or is this yet another misunderstanding of Javascript, on my part, about Javascript not being a 'classical' OOP language, and that the functionality I'm looking for wouldn't actually make sense in the context of Javascript?</p>