title: Get value from object in javascript
body: <p>I have several objects as this structure:
  <img src="https://i.stack.imgur.com/mFpaz.png" alt="enter image description here"></p>
  
  <p>Then I create a function to update the quantity of the item that matched with search ID :</p>
  
  <pre><code>function setQuantityInCartByID(json, itemID, val){
      for(var i in json){
          console.log(json[i].ID);
          if(json[i].ID == itemID){
             json[i].QuantityInCart = val;
             break;
          }
       }
       return json;
  }
  </code></pre>
  
  <p>This is my JSON ;</p>
  
  <pre><code>{"DepartmentID":12,"CategoryID":117,"BrandID":19,"BrandImage":"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;","BrandName":"General","ID":708,"Name":"Grand 6Port Power Center","PictureName":"http://111.92.241.110/wwwProducts/unknown.PNG","Notes":"","PriceShow":"$10.00","Price":0,"PriceA":0,"PriceB":0,"PriceC":0,"WebsitePrice":0,"Quantity":2,"QuantityInCart":2,"LastUpdated":"/Date(1378108144050)/","Active":1,"PriceLevel":0,"NewProductImage":"http://111.92.241.110/wwwProducts/newproduct.png","isNewProduct":false,"isInStock":"10 Available in Stock(s)!","NewArrival":0,"ExpireNewArrival":"/Date(-62135596800000)/","NewPromotion":0,"ExpireNewPromotion":"/Date(-62135596800000)/"}
  
  {"DepartmentID":12,"CategoryID":117,"BrandID":19,"BrandImage":"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;","BrandName":"General","ID":709,"Name":"Grand 6Port Power Center","PictureName":"http://111.92.241.110/wwwProducts/unknown.PNG","Notes":"","PriceShow":"$10.00","Price":0,"PriceA":0,"PriceB":0,"PriceC":0,"WebsitePrice":0,"Quantity":2,"QuantityInCart":2,"LastUpdated":"/Date(1378108144050)/","Active":1,"PriceLevel":0,"NewProductImage":"http://111.92.241.110/wwwProducts/newproduct.png","isNewProduct":false,"isInStock":"10 Available in Stock(s)!","NewArrival":0,"ExpireNewArrival":"/Date(-62135596800000)/","NewPromotion":0,"ExpireNewPromotion":"/Date(-62135596800000)/"}       
  
  {"DepartmentID":12,"CategoryID":117,"BrandID":19,"BrandImage":"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;","BrandName":"General","ID":710,"Name":"Grand 6Port Power Center","PictureName":"http://111.92.241.110/wwwProducts/unknown.PNG","Notes":"","PriceShow":"$10.00","Price":0,"PriceA":0,"PriceB":0,"PriceC":0,"WebsitePrice":0,"Quantity":2,"QuantityInCart":2,"LastUpdated":"/Date(1378108144050)/","Active":1,"PriceLevel":0,"NewProductImage":"http://111.92.241.110/wwwProducts/newproduct.png","isNewProduct":false,"isInStock":"10 Available in Stock(s)!","NewArrival":0,"ExpireNewArrival":"/Date(-62135596800000)/","NewPromotion":0,"ExpireNewPromotion":"/Date(-62135596800000)/"}
  </code></pre>
  
  <p>Problem : <code>console.log(json[i].ID);</code>result is undefined.</p>