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