Hints
for loop runs one time to get first key.
Thus,
for(var firstKey in data);
Using firstKey taking the from data object. Thus data[firstKey] returns the first value from an array object.
|
FirstKey and firstValue of the JSON
var data = {};
data.rno = 1001;
for(firstKey in data);
document.write(firstKey+"<br />");
document.write(data[firstKey]+"<br />");
|
Demo & Output
|