HELP! * GREY=local LOCAL HTML version of Foils prepared 26 February 1996

Foil 22 The MakeArray Function and Arrays of Objects - II

From CPS616 Lectures on JavaScript CPS616 Basic Information Track for Computational Science -- Winter-Spring Semester 96. by Geoffrey C. Fox * See also color IMAGE

var maxdisplay = 10;
displays = new MakeArray(maxdisplay);
for( var n=1; n <= maxdisplay; n++) {
displays[n] = new Display(n); } // set elements of displays to be objects of "class" Display
Now we have an array of Display objects of length maxdisplay which can be referenced as displays[1] ... displays[maxdisplay] with properties such as
displays[currentdisplay].pageframe; etc.
This can be nested with MakeArray used say inside a function such as Display to get variables referenced like
displays[currentdisplay].nestedarray[itsindex]; // and so on for more array indices -- this implies we put in Display
this.nestedindex = new MakeArray (whathaveyou) ;
for( var n=1; n <= whathaveyou; n++) {
nestedindex[n] = null; } // Override initialization in MakeArray



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 Tue Feb 18 1997