Export (0) Print
Expand All

arguments Property (Function) (JavaScript)

Gets the arguments for the currently executing Function object.

function.arguments

The function argument is the name of the currently executing function, and can be omitted.

This property allows a function to handle a variable number of arguments. The length property of the arguments object contains the number of arguments passed to the function. The individual arguments contained in the arguments object can be accessed in the same way array elements are accessed.

The following example illustrates the use of the arguments property:

function ArgTest(arg1, arg2){
   var s = "";
   s += "The individual arguments are: "
   for (n = 0; n < arguments.length; n++){
      s += ArgTest.arguments[n];
      s += " ";
   }
   return(s);
}
document.write(ArgTest(1, 2, "hello"));

//Output: function ArgTest(arg1, arg2){
   var s = "";
   s += "The individual arguments are: "
   for (n = 0; n < arguments.length; n++){
      s += ArgTest.arguments[n];
      s += " ";
   }
   return(s);
}
document.write(ArgTest(1, 2, "hello"));

// Output: The individual arguments are: 1 2 hello

Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Also supported Store apps (Windows 8 and Windows Phone 8.1). See Version Information.

Show:
© 2014 Microsoft