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

Foil 23 The arguments Array in JavaScript

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

function anyoldname(x1,x2) {
var argv = anyoldname.arguments;
n = anyoldname.arguments.length; // number of arguments -- same as argv.length
var y1 = anyoldname.arguments[0]; // y1 is same as this.x1 or argv[0]
var yn = anyoldname.arguments[n-1]; // last argument -- same as argv[n-1]
var wherefrom = anyoldname.caller; // use inside function to find where called from
}
This allows one to find number of arguments when called and process functions with variable number of arguments



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