contents   index   previous   next



Function property arguments[]

 

The arguments[] property is an array of all of the arguments passed to a function. The first variable passed to a function is referred to as arguments[0], the second as arguments[1], and so forth.

 

The most useful aspect of this property is that it allows you to have functions with an indefinite number of parameters. Here is an example of a function that takes a variable number of arguments and returns the sum of them all.

 

function SumAll()

{

   var total = 0;

   for (var ssk = 0; ssk < SumAll.arguments.length; ssk++)

   {

      total += SumAll.arguments[ssk];

   }

   return total;

}

 


Function recursion