As you can see, the keys are now the name of the items and the corresponding value is another object consisting of two keys - quantity and price.
var itemsToBuy = {
milk: {
quantity : 5,
price: 20
},
bread: {
quantity : 2,
price: 15
},
potato: {
quantity : 3,
price: 10
}
}
I tried but I am getting only undefined output.
Want to get data such like :
['milk', 'bread', 'potato']
[20, 15, 10]
question from:
https://stackoverflow.com/questions/65641648/how-to-get-data-from-nested-objects-in-the-form-of-array 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…