Arguments is an object similar to an array but not an array. It is similar to an array because it has the same access nature and method as an array, you can use arguments [N] to access the values of a single parameter and have the Length attribute of the array length.
In addition, the arguments object stores the parameters actually passed to the function,
It is not limited to the list of parameters defined in the function declaration,
You cannot create an arguments object explicitly. The arguments object is available only when the function starts.
Instance
Function argtest (A, B)
{
VaR S = "parameter defined by the argtest method = ";
VaR S1 = "parameters passed in by the argtest method = ";
VaR numargs = arguments. length; // obtain the value of the passed parameter.
VaR expargs = argtest. length;
S + = expargs
S + = "<br>"
S1 + = numargs
S1 + = "<br>"
For (VAR I = 0; I <numargs; I ++)
{// Obtain the parameter content.
S1 + = "Arg" + I + "=" + arguments [I] + "/N ";
}
Document. Write (S + "<br>" + S1)
}
Argtest (3 );
Note: function. Length returns the number of parameters defined by the method.