title: How to function call using 'this' inside forEach loop
body: <p>In the following object, I have a problem using the 'this' reference:</p>
  
  <pre><code>function SampleObject(){
      this.addObject = function(object){...}
      ...
      // more code here
      ...
      this.addNewObjects= function(arr){
          arr.forEach( function (obj) {
              this.addObject(new Obj(obj.prop1, obj.prop2));
          });
      }
  }
  </code></pre>
  
  <p>I'm assuming the context is changing and that 'this' refers the iterated 'obj', and not 'SampleObject'. I've solved the problem using a normal for loop however, i'm curuois to why this is not working, and would like to know if there is another way to do this.</p>