-3

Below is the JSON object I have in my JavaScript:

[{"hero title":"dsksklj","hero title2":"lsjdlk","hero text":"skjvls"}]

How can I iterate through it and save name and values in different variables?

rink.attendant.6
  • 40,889
  • 58
  • 100
  • 149

1 Answers1

0

Just like any other array:

for (var i = 0; i < array.length; i++) {
    console.log(array[i]["hero text"]);
}
tymeJV
  • 102,126
  • 13
  • 159
  • 155
  • so the key elements will be in other varaible like keys={hero text,hero title, hero title2}. then..? – Shivu MN Oct 03 '14 at 15:28