I have an object x with a bunch of properties. One of the properties is heroes which has the value of array of objects. I am interested in iterating through the array of objects of heroes and accessing specific properties from it.
Here is the code:
x = {id: "prim1", description: "planner", heroes: [{name: "arrow", universe: "dc"}, {name: "shields", universe: "marvel"}]};
I have written a simple for loop to achieve what I wanted as follows:
for (let idx = 0; idx < x.heroes.length; idx++) {
console.log(x.heroes[idx].universe);
}
How can I implement the same using the latest ES6's for of loop?
Thank you.