I have a function in JavaScript:
function test() {
console.log(arguments.length);
}
if I call it with test(1,3,5)
, it prints out 3
because there are 3 arguments. How do I call test from within another function and pass the other function's arguments?
function other() {
test(arguments); // always prints 1
test(); // always prints 0
}
I want to call other
and have it call test
with its arguments
array.