Reputation: 615
I am trying to iterate through a dynamic Object with key. Actually, my goal is to save each element of the arrays of those 2 Object keys all together into an array. How can I do it? My code:
private object: {
[key: string]: string[];
} = {};
{Product: Array(9), Brand: Array(7)}
where Product: (9) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
where Brans: (7) [{…}, {…}, {…}, {…}, {…}, {…}, {…}]
Upvotes: 0
Views: 319
Reputation: 946
Try something like this
< ES 2017:
Object.keys(obj).forEach(key => {
let value = obj[key];
});
>= ES 2017:
Object.entries(obj).forEach(
([key, value]) => console.log(key, value);
);
Upvotes: 1