25.1. The Array Object

In the first version of JavaScript, an array was implemented as a JavaScript object containing multiple property settings. Later, in JavaScript 1.1, an array was implemented as a separate Array object.

Constructors

new Array() This constructor builds a new zero-length array. Adding an element to a specified index automatically changes the length. For example,

var a = new Array();              // a.length = 0
a[12] = "foo";                    // a.length = 13

new Array(length) This constructor builds an array with indices from 0 to length-1. All the values will initially be null.

Note that this constructor is not properly recognized in Netscape's implementation of JavaScript 1.2 (Internet Explorer is fine); in Netscape this constructor produces an array ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.