JavaScript get value from nested object [duplicate]
问题 This question already has an answer here : JavaScript - retrieve value from nested object, using array of keys (1 answer) Closed 2 years ago . If this is my object: var obj = { bakery1: { small: { name: "Small cookie", price: 0.75; } large: { name: "Large cookie", price: 3.00; } } bakery2: { small: { name: "Small cookie", price: 1.00; } large: { name: "Large cookie", price: 4.00; } } }; How would I go about making a loop that prints every price to the console? And when this value is printed,