title: Javascript delegate
body: <p>I have the following the code</p>
  
  <pre><code>function createDelegate(object, method)
  {
      var shim =  function()
      {                   
           method.apply(object, arguments);
      }
      return shim;
  }
  
  
  this.test = 3;   
  var pAction = {to: this.test}
  this.tmp = createDelegate(this, function()
  {
                print("in: " + pAction.to); 
                return pAction.to;
  });
  print("out: " + this.tmp());
  </code></pre>
  
  <p>But for some reason I get the following result</p>
  
  <pre><code>in: 3
  out: undefined
  </code></pre>
  
  <p>Anyone knows the reason for this?</p>