If I have a function as such:
function doStuff(arg) {
arguments[0] = "4" + arg;
console.log(arg);
console.log.apply(null, arguments);
}
Clearly doStuff("name")
prints "4name" twice.
Do arg
and arguments[0]
point to the same thing? Can I use them interchangably. Is javascript doing anything internally that I should be aware about and are there any gotchas?
I am aware that arguments deals with all arguments passed not just the named paramaters. I only care about how it deals with the first (or nth) paramater.
[Edit]
I'm actaully using this as
function name(arg) {
arguments[1] = args;
arguments[0] = "[INFO] " + args.callee + " arg: %o";
console.log.apply(this, arguments);
}
and calling name(arguments)
in a function itself. Interestingly args.callee prints out the function source code rather then the function name.