Array [FF, IE 3]

A list of information. There are two ways to create an array:

var the_array = new Array();
var the_array = new Array(element_one, element_two, element_three...);

You can look up or change elements in an array using their position numbers (numbering starts with 0):

the_array[0] = "thau!";
window.document.writeln(the_array[0] + " wrote this book.");

Properties

length

FF, IE 3

Number of elements in an array

Example:

var my_array = new Array("eenie", "meenie", "miney", "moe");
var number_of_things = my_array.length;

The variable number_of_things holds the value 4, because there are four elements in the array.

prototype

FF, IE3

Adds properties and methods to all objects of an array. See the tutorials in "Object-Oriented Programming" on page 406. ...

Get The Book of JavaScript, 2nd 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.