Does Array.pop() mess array's length?
<p>I am trying the following code in ideone:</p>

<pre><code>var a = [];
a[0] = 0;
a[5] = 5;
a[6] = undefined;
print("contents before popping:");
for(var e in a) print("\ta[", e, "] =", a[e]);
print("a.length =", a.length);
for (var i = 0; i &lt; a.length; i++) 
    print("\ta.hasOwnProperty(", i, ") =", a.hasOwnProperty(i));

print("popping --&gt;", a.pop());
print("popping --&gt;", a.pop());
print("contents after popping:");
for(var e in a) print("\ta[", e, "] =", a[e]);
print("a.length =", a.length);
for (var i = 0; i &lt; a.length; i++) 
    print("\ta.hasOwnProperty(", i, ") =", a.hasOwnProperty(i));
</code></pre>

<p>The output goes as follows:</p>

<pre><code>contents before popping:
    a[ 0 ] = 0
    a[ 5 ] = 5
    a[ 6 ] = undefined
a.length = 7
    a.hasOwnProperty( 0 ) = true
    a.hasOwnProperty( 1 ) = false
    a.hasOwnProperty( 2 ) = false
    a.hasOwnProperty( 3 ) = false
    a.hasOwnProperty( 4 ) = false
    a.hasOwnProperty( 5 ) = true
    a.hasOwnProperty( 6 ) = true
popping --&gt; undefined
popping --&gt; 5
contents after popping:
    a[ 0 ] = 0
a.length = 5
    a.hasOwnProperty( 0 ) = true
    a.hasOwnProperty( 1 ) = false
    a.hasOwnProperty( 2 ) = false
    a.hasOwnProperty( 3 ) = false
    a.hasOwnProperty( 4 ) = false
</code></pre>

<p>In my JavaScript book (well, Crockford's) I read that array's length is calculated as the biggest numerical value of all properties. So, why does it say the length is 5 when the biggest numerical property it has is 0? Thanks!</p>
