title: Angular modifies properties when forEach or pure For
body: <p>Here's the <strong>Plunker</strong>:
  <a href="https://plnkr.co/edit/itgraL2X6gCHCs7tgSZi" rel="nofollow">https://plnkr.co/edit/itgraL2X6gCHCs7tgSZi</a></p>
  
  <p>I have 2 collections</p>
  
  <pre><code> $scope.params = [{
          id: 1,
          nombre: 'bloom'
        }, {
          id: 2,
          nombre: 'ctotal'
        }, {
          id: 3,
          nombre: 'coliformes'
  }];
  
  $scope.puntos = [{
          id: 1,
          nombre: 'votator'
        }, {
          id: 2,
          nombre: 'vw1'
        }, {
          id: 3,
          nombre: 'preparador'
        }];
  </code></pre>
  
  <p>My code in the controller looked like:</p>
  
  <pre><code>angular.forEach($scope.puntos, function(punto, key) {
          punto.params = $scope.params;
          angular.forEach(punto.params, function(pa, key) {
              pa.otherProp = "xxxxx";
      });
  });
  </code></pre>
  
  <p>As you can see, I want to assign the params collection to each item in the puntos collection. Then I assign to the item inside the collection a value in the otherProp property.....I never change the main $scope.params....but if I output both this has changed too</p>
  
  <p>Then my output is:</p>
  
  <pre><code>Puntos
  
  {"id":1,"nombre":"votator","params":[{"id":1,"nombre":"bloom","otherProp":"xxxxx"},{"id":2,"nombre":"ctotal","otherProp":"xxxxx"},{"id":3,"nombre":"coliformes","otherProp":"xxxxx"}]}
  {"id":2,"nombre":"vw1","params":[{"id":1,"nombre":"bloom","otherProp":"xxxxx"},{"id":2,"nombre":"ctotal","otherProp":"xxxxx"},{"id":3,"nombre":"coliformes","otherProp":"xxxxx"}]}
  {"id":3,"nombre":"preparador","params":[{"id":1,"nombre":"bloom","otherProp":"xxxxx"},{"id":2,"nombre":"ctotal","otherProp":"xxxxx"},{"id":3,"nombre":"coliformes","otherProp":"xxxxx"}]}
  Params
  
  {"id":1,"nombre":"bloom","otherProp":"xxxxx"}
  {"id":2,"nombre":"ctotal","otherProp":"xxxxx"}
  {"id":3,"nombre":"coliformes","otherProp":"xxxxx"}
  </code></pre>
  
  <p>At first I tought that the problem was caused by using angular.forEach....So i decided to use a pure for.....the problem appears instead</p>
  
  <pre><code>for (var i = 0; i &lt; $scope.puntos.length; i++) {
      var punto = $scope.puntos[i];
      punto.params = [];
      punto.params = $scope.params;
      for (var j = 0; j &lt; punto.params.length; j++){
        var pa = punto.params[j];
        pa.otherProp = 'yyyyyy';
      }
  }
  </code></pre>
  
  <p>Of course this is a simmple example...what I really want is more complex but this is stopping me...</p>
  
  <p>Why is the params collection modified even If i didn't change it Manually?
  Hoy to prevent it?</p>
  
  <p>Thanks in advance</p>