for in loop in javascript
<p>i am trying to understand  following  fragment of  javascript code</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;body&gt;
&lt;p&gt;Click the button to loop through the properties of an object named "person".&lt;/p&gt;
&lt;button onclick="myFunction()"&gt;Try it&lt;/button&gt;
&lt;p id="demo"&gt;&lt;/p&gt;

&lt;script type="text/javascript"&gt;
function myFunction()
{
var x;
var txt="";
var person={fname:"John",lname:"Doe",age:25}; 

for (x in person)
{
txt=txt + person[x];
}

document.getElementById("demo").innerHTML=txt;
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>i am a little confused with this line</p>

<pre><code>for (x in person)
    {
    txt=txt + person[x];
    }
</code></pre>

<p>as i  guessed  it is a   associative array,with key--> value relationship and as a final result  should not it print  like this?</p>

<pre><code>fname:"John",lname:"Doe",age:25
</code></pre>

<p>?
thanks very much</p>
