I have declared a triple nested object, like so:
var food = {
    "fruit": {
        "apples": {
            "redApples": 20,
            "greenApples": 30
        },
        "bananas": {
            "yellowBananas": 10
        }
    },
    "grains": {
        "bread": {
            "brownBread": 50
        }
    }
};
I found this question, which worked for iterating through an object of an object, but I'm stuck. How would I iterate through this object?
Update: For this specific problem, nested for-loops would work fine, like this:
for(var key in food)
    for(var prop in food[key])
        for(var foo in food[key][prop])
            console.log(food[key][prop][foo]);
However, there are some good recursive functions below which would do this for indefinitely nested objects.
 
     
     
     
    