Appendix B. Data

Array Object

The Array object is used to store multiple values in a single variable. Syntax for creating an Array object:

var myCars=new Array("Saab","Volvo","BMW")

To access and to set values inside an array, you must use the index numbers as follows:

  • myCars[0] is the first element

  • myCars[1] is the second element

  • myCars[2] is the third element

Array Object Properties

Property

Description

FF

IE

constructor

Returns a reference to the array function that created the object

1

4

index

Returns zero based index of the match in the string

1

4

input

Returns original string against which regular expression was matched

1

4

length

Sets or returns the number of elements in an array

1

4

prototype

Allows you to add properties and methods to the object

1

4

Array Object Methods ...

Get Scriptin’ with JavaScript and Ajax: A Designer’s Guide 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.