mozilla

Compare Revisions

Array.prototype.length

Change Revisions

Revision 417563:

Revision 417563 by Sheppy on

Revision 445009:

Revision 445009 by simone on

Title:
Array.length
Array.length
Slug:
Web/JavaScript/Reference/Global_Objects/Array/length
Web/JavaScript/Reference/Global_Objects/Array/length
Tags:
"Array"
"Array"
Content:

Revision 417563
Revision 445009
tt55    <p>
56      By the way, <code>length</code> actually doesn't return the
 > number of elements in an array, but the last index + 1. In fact,
 > if you run this code:
57    </p>
58    <pre class="brush:js">
59var a = [];
60a[40] = 'foo';  
61alert(a.length);
62</pre>
63    <p>
64      Will alert 41.
65    </p>
66    <p>
67      &nbsp;
68    </p>

Back to History