Get items quantity in js object
<p>I need get  js object properties count.</p>

<p>I search and found solutions like this:</p>

<pre><code>var foo = {"key1": "value1", "key2": "value2", "key3": "value3"};
var count = 0;
for (var k in foo) {
    if (foo.hasOwnProperty(k)) {
      ++count;
    }
}
</code></pre>

<p>Question: why needed condition <code>if (foo.hasOwnProperty(k)) {</code> ?</p>

<p>I think that this code must work good always, without this condition also. </p>

<p>I am wrong?</p>
