Basic HTML version of Foils prepared 23 June 1997

Foil 31 Arrays in JavaScript - I

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo

Arrays Example
In Navigator 3, we write:
var area = new Array();
area[0] = "Alabama";
area[1] = "Alabama";
area[2] = "Alaska"; // etc.
var acode = new Array();
acode[0] = 205; // mapping area codes to states
acode[1] = 334;
acode[2] = 907;
area.length gives the length of the array ( 3 in this case)
Note you can set array elements to be objects to make arrays of objects:
menuArray = new Array();
menuArray[0] = new MenuObject(1, 'world');
worldMenu = menuArray[0]; // a synonym



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998