consider the following:
foo intends to take the arguments object and rearrange the order, moving arg1 to the position of arg2
function foo (args) {
args[2] = args[1];
args[1] = undefined;
}
bar
calls foo with it's arguments
function bar (a, b, c) {
foo(arguments);
console.log(arguments);
}
I expect the result of the following to be something like { 0: 'hello', 1: undefined, 2: 'world' }
bar('hello', 'world');
However, i get:
{
0: 'hello',
1: undefined,
2: 'world',
3: undefined,
4: undefined,
5: undefined,
6: undefined,
7: undefined,
8: undefined,
9: undefined,
10: undefined,
11: undefined,
12: undefined,
13: undefined,
14: undefined,
15: undefined,
16: undefined,
17: undefined,
18: undefined,
19: undefined
}
I am at a complete loss as to why this happens. Anyone have any ideas?
I'm running this in a node.js environment