I have a json array like this
var data = key: [
{
arr1: [
{value: 1},
{value: 2},
{value: 3},
]
},
{
arr2: [
{value: 1},
{value: 2},
{value: 3},
]
},
{
arr3: [
{value: 1},
{value: 2},
{value: 3},
]
}
]
I wanted to loop through key
which is 3 times, and inside the key loop I wanted loop again through each of the elements inside key
.
First I tried $.each
which works fine for key array. And inside the each function I tried to get the key values using Object.key(this)
inside the loop which returned me the names
arr1, arr2, arr3
But I'm not able to loop through the names I got.
$.each(data, function(i, e) {
Object.keys(this).each(function(index, element) {
console.log(element);
})
})
I don't know if this is the right way of doing it, when I tried doing it this was. I got an error telling .each
is not a function.
Any help will be much appreciated.