Knowledge Walls
John Peter
Pune, Maharashtra, India
How to get first key of json object in javascript with Example.
36194 Views
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 
Best Lessons of "Good Javascript Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details