This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

arguments

Summary

Gets the arguments for the currently executing Function object.

Syntax

function.arguments

Examples

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

Remarks

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.

See also

Other articles

Attributions

  • Microsoft Developer Network: Article