title: 'this' is undefined inside the foreach loop
body: <p>I am writing some typescript code and iterating an array. Inside the loop, I am trying to access 'this' object to do some processing as:</p>
  
  <pre><code>console.log('before iterate, this = ' +this);
  myarray.days.forEach(function(obj, index) {
      console.log('before transform, this : ' + this);
      this.datePipe.transform...
  });
  </code></pre>
  
  <p>but this fails, as it complains that 'this' is undefined 
  'this' object prints correctly as [object object] before/outside the loop, but inside the loop, it is undefined. Why is that? And what is the fix for that?</p>