Possible Duplicate:
Calling dynamic function with dynamic parameters in Javascript
javascript array parameter list
I’m looking for the Javascript equivalent of the following functionality I use in PHP:
function myfunc()
{
$arg_arr = array();
$arg_arr = func_get_args();
$my_arg_val_1 = (!isset($arg_arr[1]) || ($arg_arr[1] == '')) ? true : $arg_arr[1];
}
Basically, I’m trying to get the function arguments. I want to write a javascript function to take one argument, but I want to add some code to do a few things with the second and third argument if it is provided, but I’m not sure how to pull this off.
Any assistance will be appreciated.
Thanks.
In JavaScript there is
argumentsvariable available in each function. It looks like an array which contains all arguments passed to a function: