title: How to bind a function to every other function call?
body: <p>Today I painstakingly merged several thousand lines of code from three different files into a single .js file. The files all had the same origin but evolved in different projects with some slight (but crucial) differences.</p>
  
  <p>I managed to merge the thingies and kept all the best stuff from the duplicate functions.
  So far so good...</p>
  
  <p>But now I'm still stuck with around 1700 lines of JavaScript of which a lot might still be redundant or completely obsolete.</p>
  
  <p>To solve this problem I came up with the following idea: can I bind a function to the Function.prototype so I can keep track of the usefulness of the functions in the project?</p>
  
  <p>So far I've come up with this, but it requires me to add code to every function, which is no good.</p>
  
  <pre><code>Function.prototype.useful= function () {
      // This should be called by every function.
      console.log(this.name);
  };
  
  function someFunction() {
      arguments.callee.useful(); // No good.
      // Irrelevant.
  }
  
  someFunction();
  </code></pre>
  
  <p>Can I make this so every (non-native) function calls <code>useful()</code> automatically? </p>