Closed vin closed 12 years ago
> var arguments = [1, 2, 3];
undefined
> arguments
[ 1, 2, 3 ]
> var args = Array.prototype.slice(arguments);
undefined
> args
[]
> args.unshift('up')
1
> args
[ 'up' ]
> var a = function () {
var args = Array.prototype.slice(arguments);
args.unshift('up');
console.log(args);
};
undefined
> a(1, 2);
[ 'up' ]
It doesn't seems to work.
I changed this line:
var args = Array.prototype.slice(arguments);
by:
var args = Array.prototype.slice.call(arguments);
Woops, thanks. Next time I'll test it first :-X
Now a call like
is the same as
Before this change, the caller had to pass in a dummy first argument like