title: Array Push Overwrite
body: <p>A record has an old color/number and new properties, which can be changed. I want to loop through an array and check to see if the old and new values don't match. If they don't, I'd like to determine which property was changed (color/number), set that record's changed property, and push it to an array. If the record has changes for both color and number, I want a copy of each array entry with the different changed property. </p>
  
  <p>I've tried a few different ways and the push is overwriting the changed property, no matter what I do. I've tried to use a local array and that didn't work out either. Here is an example. </p>
  
  <pre><code> export class Record {
   id: string;
   oldcolor: string;
   newcolor: string;
   oldnumber: string;
   newnumber: string;
   changed: string;
  }
  
  
  
  
  @Input() newrecords: Record[];
  output: Record[] = [];
  
  functionTest() {
  
      for (let rec of this.newrecords) {
  
  
              if (rec.newcolor != rec.oldcolor) {
  
                  rec.changed  = "color";
                  output.push(rec);
  
  
          }
  
              if (rec.newnumber != rec.oldnumber) {
  
                  rec.changed = "number";
                  output.push(rec);
  
              }
  
  
          }
      }
  
  
  desired result
  [{
   id: 1;
   oldcolor: red;
   newcolor: red;
   oldnumber: 6;
   newnumber: 6;
   changed: color;
  },
  {
   id: 1;
   oldcolor: red;
   newcolor: red;
   oldnumber: 6;
   newnumber: 6;
   changed: number;
  }]
  </code></pre>