function foo(x1, x2) { |
// the arguments array: |
var argv = foo.arguments; |
// number of arguments (same as argv.length): |
var n = foo.arguments.length; |
// y1 is same as this.x1 or argv[0]: |
var y1 = foo.arguments[0]; |
// the last argument (same as argv[n-1]): |
var yn = foo.arguments[n-1]; |
// use inside function to determine caller: |
var wherefrom = foo.caller; |
} |
This allows one to process functions with a variable number of arguments |
The arguments array is a property of all user-defined functions and Function objects. |