-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
  • 44,500
  • 61
  • 101
  • 156

1 Answers1

0

Just like any other array:

for (var i = 0; i < array.length; i++) {
    console.log(array[i]["hero text"]);
}
tymeJV
  • 103,943
  • 14
  • 161
  • 157
  • 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