I currently have data structued as
{
{id:
{prop: value}
},
{anotherId:
{prop: value}
}
}
and I want to convert it into an array of objects:
[
{id:
{prop: value}
},
{anotherId:
{prop: value}
}
]
How can I acplish this?
I currently have data structued as
{
{id:
{prop: value}
},
{anotherId:
{prop: value}
}
}
and I want to convert it into an array of objects:
[
{id:
{prop: value}
},
{anotherId:
{prop: value}
}
]
How can I acplish this?
Share Improve this question edited Oct 24, 2019 at 18:29 Samuel Rosenstein asked Oct 24, 2019 at 11:54 Samuel RosensteinSamuel Rosenstein 3744 silver badges15 bronze badges 3- 2 I'm not sure what that screenshot is trying to municate. Could you edit the question to show exactly what you have, and what exactly you would like it to be instead, including the code that you've tried that doesn't work the way you expect? – Doug Stevenson Commented Oct 24, 2019 at 12:06
- 1 You don't manipulate data with React--AFAICT there's nothing React or even Firebase about this question--it's just JS. – Dave Newton Commented Oct 24, 2019 at 12:34
- Thanks for the feedback, see the edited question. The answer that Anthony gave solved my issue. – Samuel Rosenstein Commented Oct 24, 2019 at 18:31
1 Answer
Reset to default 9You could use Object.values()
const obj = {
a: { 1: 'something', 2: 'something else' },
b: { 1: 'something', 2: 'something else' }
};
console.log(Object.values(obj));