-1

I have an Object like this:

{
    1: [{'id':'1','value':'aa'}],
    2: [{'id':'2', 'value':'aa'}, {'id':'2','value':'bb'}],
    3: [{'id':'34', 'value':'cc'}]
}

enter image description here

How should I iterate that object? I'm very confused about it

I tried things like:

// object es my var 
Array.from(object).forEach(a => {
    console.log(a)
});

Array.prototype.forEach.call(object, child => {
    console.log(child)
});

With out success

pmiranda
  • 7,602
  • 14
  • 72
  • 155

1 Answers1

0

Just do a for in loop:

for (var property in object) {
  //Do stuff here
}
  • 1
    This is an **often repeated** duplicate. It doesn't need an answer, just a close vote and (in some cases) a comment. – T.J. Crowder Dec 20 '19 at 18:41