JS dynamic json array creation is not working in IE 11

I have to make a dynamic JSON array using js. My code is like

var item_id=document.getElementById(vendor_id+"item-id"+i).innerHTML;
     var quantity=document.getElementById(vendor_id+"quantity"+i).value;
     var unit_price=document.getElementById(vendor_id+"unit-price"+i).innerHTML;
     var sub_total=document.getElementById(vendor_id+"price"+i).innerHTML;
     item={
      item_id:item_id,
      quantity:quantity,
      price:unit_price,
      sub_total:sub_total
     }
     console.log(item.item_id);
     products.push(item);

When I run this on chrome, I am getting the item array, also getting the console print item_id.
But when I run this on IE 11 the console print is undefined

item.item_id is undefined

How can I change this to work in all browsers?

11 thoughts on “JS dynamic json array creation is not working in IE 11”

Leave a Comment