Is this legal? And does it work in all browsers?
function func1(a, b, c) {
//b == 2 here
change_em(arguments);
//b should equal 3 here
}
function change_em(args) {
args[0] = 6;
args[1]++;
args[2] = [];
}
func1('foo', 2);
If you are wondering, I need to adjust the arguments in a function. A macro would be perfect, except javascript doesn't have one. Doing it properly, i.e. passing the variables to a function, then returning them in an object, and then extracting them in the caller would be almost as much code as just copy/pasting the adjuster function.