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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.