Basic HTML version of Foils prepared 23 June 1997

Foil 33 Arrays in JavaScript - III

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

Arrays Example
One can easily define and use multidimensional arrays:
  • MenuArray[0].options[0] = 'Admin';
  • MenuArray[0].options[1] = 'FoilWorld'; // etc.
Arrays (in NN 3.0) have some interesting methods:
  • myArray.sort(sortMethod)
  • returns an array sorted according to the optional sortMethod (a user-defined, boolean function comparing two elements)
  • myArray.join(separator)
  • returns a string of elements separated by the character separator
  • myArray.reverse()
  • reverses the order of the elements in the array
myArray = new Array(InitSize,val0,val1,...);
specifies an initial size and initial values of the array. The arguments are optional and undefined initial values are set to null.



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