for loops in object within object
<p>Can someone explain why doesn't this work?</p>

<p>I have two objects within an object. I use for loops to print out each property within the nested objects, one after another.</p>

<pre><code>var people = {
    john: {
        name: "John",
        age: 20
    },
    bob: {
        name: "Bob",
        age: 40
    }
};

for (var person in people) {
    for (var property in person) { 
        console.log(property);
    }
}
</code></pre>

<p>I expect it to print out:</p>

<pre><code>name
age
name
age
</code></pre>

<p>Instead I get:</p>

<pre><code>0
1
2
3
0
1
2
</code></pre>

<p>1) What am I doing wrong?</p>

<p>2) What exactly is the console doing to output the numbers above?</p>
