title: Override javascript function while preserving the original context
body: <p>I just want to confirm that I'm not missing something with regards to managing context and overriding methods. I'm using the http-proxy module in a node.js app and I need to override the function HttpProxy.prototype.proxyRequest. I'd like to do it without modifying the original module code directly but haven't been able to find a way to do it.</p>
  
  <p>If I do this:</p>
  
  <pre><code>var httpProxy = require('http-proxy'),
  httpProxyOverride = require('./http-proxy-override.js');
  
  httpProxy.HttpProxy.prototype.proxyRequest = httpProxyOverride.proxyRequestOverride;
  </code></pre>
  
  <p>Then I lose the original context and errors are thrown. If I use apply(), I can provide a new context, but it doesn't appear I can persist the original context.</p>
  
  <p>Based off of this SO thread:
  <a href="https://stackoverflow.com/questions/12336044/is-it-possible-to-call-function-apply-without-changing-the-context">Is it possible to call function.apply without changing the context?</a>
  It doesn't appear that there is a way to achieve what I'm trying to do and I'm hoping that someone can confirm this or correct me if I'm wrong.</p>