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
1 In Navigator 3, we write:
2 var area = new Array();
3 area[0] = "Alabama";
4 area[1] = "Alabama";
5 area[2] = "Alaska"; // etc.
6 var acode = new Array();
7 acode[0] = 205; // mapping area codes to states
8 acode[1] = 334;
9 acode[2] = 907;
10 area.length gives the length of the array ( 3 in this case)
11 Note you can set array elements to be objects to make arrays of objects:
12 menuArray = new Array();
13 menuArray[0] = new MenuObject(1, 'world');
14 worldMenu = menuArray[0]; // a synonym

in Table To:


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