I have a json object r:
[
{
"id" : "3443",
"name" : "Joe",
"date1" : "254",
"date4" : "261"
},
{ "id" : "50942",
"name" : "John",
"date2" : "192",
"date4" : "195"
},
{ "id" : "2524",
"name" : "Mary",
"date1" : "153",
"date4" : "163"
}
]
and I wish to have a Javascript For loop to go through the dateX values. I know that X is between 1 and a Max value.
But following code does not work:
for (j=1; j<=Max; j=j+1) {
datestring = 'date' + j;
if (isset(r[i].datestring)) value[j] = r[i].datestring;
else value[j] = null;
}
Forgot to explain that I defined the isset function as:
function isset(variable) {
return typeof(variable) != "undefined" && variable !== null;
}
issetanywhere?issetexists as a function in PHP, but not JavaScript.