I'm trying to generate a dynamic array of type {}
tabla.each(function() {
var ID = $(this).find('td:eq(0)').html();
var fechaingre = $(this).find("input[id*='dfi']").val();
var fechafin = $(this).find("input[id*='dff']").val();
var canadul = $(this).find("select[id*='adul']").val();
var canchil = $(this).find("select[id*='chil']").val();
var pre = sessionStorage.key(au);
var valorprecio = sessionStorage.getItem(pre);
item = {};
if (ID !== '') {
item["id"] = ID;
item["fechain"] = fechaingre;
item["fechafin"] = fechafin;
item["pre"] = valorprecio;
item["adult"] = canadul;
item["chil"] = canchil;
var room = sessionStorage.getItem("users");
array_room = JSON.parse(room);
var habitacion = array_room[au];
item["idroom"] = habitacion.id;
item.push(item);
}
au++;
});
console.log(item);
However when printing in console item shows error.
what would be the correct way to generate a dynamic array of the type
{
"ID": "1",
"fechain": "20160101",
},
{
"ID": "2",
"fechain": "20160201"
}