title: What does the "this" keyword refer to in the following Javascript code?
body: <p>This is an example from <em>JavaScript:The Definitive Guide by David Flanagan</em>  </p>
  
  <pre><code>//Replace the method named m of the object o with a version that logs messages before and after invoking the original method.
  
  function trace(o, m) {
    var original = o[m];                            // Remember original method in the closure.
    o[m] = function() {                             // Now define the new method.
      console.log(new Date(), "Entering:", m);      // Log message.
      var result = original.apply(this, arguments); // Invoke original.
      console.log(new Date(), "Exiting:", m);       // Log message.
      return result;                                // Return result.
    };
  }
  </code></pre>
  
  <p>I understand that since m is a method of o, 'this' should refer to the object o. But I cannot understand how; because in a function 'this' should refer to the global object (non-strict mode).<br>
  Also, how does the 'arguments' array contain the original function's arguments and not of the anonymous wrapper function's?</p>