Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Loop through an array inside an object javascript

I have this javascript object children with multiple array inside and the array names are random.

enter image description here

how can i loop through it without specifying ‘S801’, ‘S901’ etc so i can get some result like

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[52.4655012, 13.2595648], [21.1006158, 79.0074763] , ……

>Solution :

Use Object.values to get the values in the Object and then map over it.

const obj = {
  children: {
    S801: [52, 13],
    S901: [21, 79]
  }
};

Object.values(obj.children).map(([value1,value2]) => {
  console.log(value1,value2)
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading