Share via


arguments Object (JScript 5.6) 

An object representing the arguments to the currently executing function, and the functions that called it.


[function.]arguments[n]

Arguments

  • function
    Optional. The name of the currently executing Function object.
  • n
    Required. The zero-based index to argument values passed to the Function object.

Remarks

You cannot explicitly create an arguments object. The arguments object only becomes available when a function begins execution. The arguments object of the function is not an array, but the individual arguments are accessed the same way array elements are accessed. The index n is actually a reference to one of the 0n properties of the arguments object.

Example

The following example illustrates the use of the arguments object.

function ArgTest(a, b){

   var i, s = "The ArgTest function expected ";

   var numargs = arguments.length;     //Get number of arguments passed.

   var expargs = ArgTest.length;       //Get number of arguments expected.

   if (expargs < 2)

      s += expargs + " argument. ";

   else

      s += expargs + " arguments. ";

   if (numargs < 2)

      s += numargs + " was passed.";

   else

      s += numargs + " were passed.";

   s += "\n\n"

   for (i =0 ; i < numargs; i++){      //Get argument contents.

   s += "  Arg " + i + " = " + arguments[i] + "\n";

   }

   return(s);                          //Return list of arguments.

}

Requirements

Version 1

See Also

Reference

0...n Properties (JScript 5.6)
callee Property (JScript 5.6)
caller Property (JScript 5.6)
length Property (arguments) (JScript 5.6)