I have this following object:
{ 12232: [], 34232: [], 23435: [] } I want to extract the keys from this object to show them as labels in my React frontend. How can I accomplish this?
The method Object.keys() allows you to loop over the keys of an object. You should be able to use it in order to get what you want.
You can always use
obj = { abc: "1", def: "2" } console.log(Object.keys(obj)) It will log ["abc", "def"]. Then you can map through this array and display the values as required.
You could use Object.keys to extract the keys out of your object.
You could check the docs of Object.keys here
const obj = { 12232 : [], 34232 : [], 23435: [] } Object.keys(obj); // returns ['12232', '34232', '23435'];
Object.keys(theObject)to get an array of keys.{ foo: 'bar' }is a JSO but not a JSON, while{ "foo": "bar" }is both.