title: jQuery/Javascript get notified when a function is executed
body: <pre><code>var f = function() {
      // Do something useful here
  };
  </code></pre>
  
  <p>Is there a way to 'observe' this function, and get notified when it is executed? Something similar to <em>bind</em> in jQuery, but I want to <em>bind</em> functions and not dom events?</p>
  
  <p>I <strong>don't want</strong> something like this:</p>
  
  <pre><code>var f = function() {
      // Do something useful here
      notifyObserver();
  };
  </code></pre>
  
  <p>but <strong>I want</strong> something like this:</p>
  
  <pre><code>f.bind(function() {
      alert('F was executed.');
  });
  </code></pre>