title: Add new object property to JSON response in Angular
body: <p>I'm trying to add a new object property to my JSON response.</p>
  
  <p>My sample JSON response</p>
  
  <pre><code>{
      "products": [{
          "id": 1,
          "name": "xyz"
      }]
  }
  </code></pre>
  
  <p>After getting the response need to add new object property(show) to the same JSON response</p>
  
  <pre><code>{
      "products": [{
          "id": 1,
          "name": "xyz",
          "show": false
      }]
  }
  </code></pre>
  
  <p>This is my sample code</p>
  
  <pre><code>import {Component,OnInit} from '@angular/core';
      import {Http, Response} from '@angular/http';
      import 'rxjs/Rx';
      @Component({
        templateUrl:'./electronics.html'
      })
      export class electronicsComponent{
        productListElectronics={};
          productListElectronicResponse: Object;
          error:Object;
          constructor(private http: Http) {
            this.productListElectronicResponse={};
              this.error={};
              http.get('../json/electronics/electronics.json').map((res: Response) =&gt;res.json()).subscribe(res =&gt;
                {
  
                  for(var i = 0; i &lt;= res['products'].length; i++){
                      res['products'][i].show=false;
                    }
                    console.log(res);
             }, error =&gt; this.error = error );
        }
      }
  </code></pre>
  
  <p>But console keeps on throwing the following error:</p>
  
  <blockquote>
  <pre><code>ERROR TypeError: Cannot set property 'show' of undefined
      at SafeSubscriber.http.get.map.subscribe._this.error [as _next] (products.component.ts:22)
      at SafeSubscriber.__tryOrUnsub (Subscriber.ts:238)
      at SafeSubscriber.next (Subscriber.ts:190)
      at Subscriber._next (Subscriber.ts:135)
      at Subscriber.next (Subscriber.ts:95)
      at MapSubscriber._next (map.ts:80)
      at MapSubscriber.Subscriber.next (Subscriber.ts:95)
      at XMLHttpRequest.onLoad (xhr_backend.ts:104)
      at ZoneDelegate.invokeTask (zone.js:398)
      at Object.onInvokeTask (ng_zone.ts:253)
      at ZoneDelegate.invokeTask (zone.js:397)
      at Zone.runTask (zone.js:165)
      at XMLHttpRequest.ZoneTask.invoke (zone.js:460)
  </code></pre>
  </blockquote>