mozilla

Compare Revisions

Array

Change Revisions

Revision 27810:

Revision 27810 by Sevenspade on

Revision 27811:

Revision 27811 by Maciekp on

Title:
Array
Array
Slug:
JavaScript/Reference/Global_Objects/Array
JavaScript/Reference/Global_Objects/Array
Tags:
JavaScript, NeedsEditorialReview, "JavaScript Reference"
JavaScript, NeedsEditorialReview, "JavaScript Reference"
Content:

Revision 27810
Revision 27811
n34        If the first argument passed to the <code>Array</code> con34        If the first argument passed to the <code>Array</code> co
>nstructor is an integer between 0 and 2<sup>32</sup>-1 (inclusive>nstructor is an integer between 0 and 2<sup>32</sup>-1 (inclusive
>), a new array is created with that number of elements. If the ar>), a new array is created with that number of elements. If the ar
>gument is any other number, a <code><a href="en/JavaScript/Refere>gument is any other number, a <code><a href="/en/JavaScript/Refer
>nce/Global_Objects/RangeError" title="en/JavaScript/Reference/Glo>ence/Global_Objects/RangeError" title="en/JavaScript/Reference/Gl
>bal_Objects/RangeError">RangeError</a></code> exception is thrown>obal_Objects/RangeError">RangeError</a></code> exception is throw
>.>n.
n44      Note that <a class="external" href="http://www.andrewdupontn44      Note that <a class="external" href="http://www.andrewdupont
>.net/2006/05/18/javascript-associative-arrays-considered-harmful/>.net/2006/05/18/javascript-associative-arrays-considered-harmful/
>">you shouldn't use an array as an associative array</a>. You can>">you shouldn't use an array as an associative array</a>. You can
> use plain <a href="en/JavaScript/Reference/Global%20Objects/Obje> use plain <a href="/en/JavaScript/Reference/Global_Objects/Objec
>ct" title="en/JavaScript/Reference/Global Objects/Object">objects>t" title="en/JavaScript/Reference/Global Objects/Object">objects<
></a> instead, although doing so comes with its own caveats. See t>/a> instead, although doing so comes with its own caveats. See th
>he post <a class=" external" href="http://monogatari.doukut.su/20>e post <a class="external" href="http://monogatari.doukut.su/2010
>10/12/lightweight-javascript-dictionaries.html" title="http://mon>/12/lightweight-javascript-dictionaries.html" title="http://monog
>ogatari.doukut.su/2010/12/lightweight-javascript-dictionaries.htm>atari.doukut.su/2010/12/lightweight-javascript-dictionaries.html"
>l">Lightweight JavaScript dictionaries with arbitrary keys</a> as>>Lightweight JavaScript dictionaries with arbitrary keys</a> as a
> an example.>n example.
n55console.log(arr[2]);              // prints "this is the second en55console.log(arr[1]);              // prints "this is the second e
>lement">lement"
t96      An array's <code><a href="/en/JavaScript/Reference/Global_Ot96      An array's <code><a href="/en/JavaScript/Reference/Global_O
>bjects/Array/length" title="en/JavaScript/Reference/Global_Object>bjects/Array/length" title="en/JavaScript/Reference/Global_Object
>s/Array/length">length</a></code> property and numerical properti>s/Array/length">length</a></code> property and numerical properti
>es are connected.&nbsp; Several of the built-in array methods (e.>es are connected.&nbsp; Several of the built-in array methods (e.
>g., <code><a href="/en/JavaScript/Reference/Global_Objects/Array/>g., <code><a href="/en/JavaScript/Reference/Global_Objects/Array/
>join" title="en/JavaScript/Reference/Global_Objects/Array/join">j>join" title="en/JavaScript/Reference/Global_Objects/Array/join">j
>oin</a></code>, <code><a href="/en/JavaScript/Reference/Global_Ob>oin</a></code>, <code><a href="/en/JavaScript/Reference/Global_Ob
>jects/Array/slice" title="en/JavaScript/Reference/Global_Objects/>jects/Array/slice" title="en/JavaScript/Reference/Global_Objects/
>Array/slice">slice</a></code>, <code><a href="/en/JavaScript/Refe>Array/slice">slice</a></code>, <code><a href="/en/JavaScript/Refe
>rence/Global_Objects/Array/indexOf" title="en/JavaScript/Referenc>rence/Global_Objects/Array/indexOf" title="en/JavaScript/Referenc
>e/Global_Objects/Array/indexOf">indexOf</a></code>, etc.) take in>e/Global_Objects/Array/indexOf">indexOf</a></code>, etc.) take in
>to account the value of an array's <code>length</code> property w>to account the value of an array's <code>length</code> property w
>hen they're called.&nbsp; Other methods (e.g., <code><a href="en/>hen they're called.&nbsp; Other methods (e.g., <code><a href="/en
>JavaScript/Reference/Global_Objects/Array/push" title="en/JavaScr>/JavaScript/Reference/Global_Objects/Array/push" title="en/JavaSc
>ipt/Reference/Global_Objects/Array/push">push</a></code>, <code><>ript/Reference/Global_Objects/Array/push">push</a></code>, <code>
>a href="en/JavaScript/Reference/Global_Objects/Array/splice" titl><a href="/en/JavaScript/Reference/Global_Objects/Array/splice" ti
>e="en/JavaScript/Reference/Global_Objects/Array/splice">splice</a>tle="en/JavaScript/Reference/Global_Objects/Array/splice">splice<
>></code>, etc.) also result in updates to an array's <code>length>/a></code>, etc.) also result in updates to an array's <code>leng
></code> property.>th</code> property.

Back to History