Consider this JavaScript function:
var f = function (a) {
console.log(a+" "+arguments[0]);
a = 3;
console.log(a+" "+arguments[0]);
}
I would expect that a
and arguments[0]
reference the same value only up to the second statement of the function. Instead they appear to always refer the same value: f(2)
causes
2 2
3 3
and f({foo: 'bar'})
causes:
[object Object] [object Object]
3 3
Are argument identifiers and the arguments
identifier linked in a special way?