Change Language


Follow Navioo On Twitter

Arguments : Object

An array of parameters passed to a function.

Platform Support

IE Mozilla Netscape Opera Safari
4.0+ 1.0+ 3.0+ 7.0+ 1.0+

Constructors

Constructor Action IE Mozilla Netscape Opera Safari
Arguments Constructor() : Arguments
Creates a new instance of the Arguments array.
Show Details 4.0+ 1.0+ 3.0+ 7.0+ 1.0+

Arguments() : Arguments

Creates a new instance of the Arguments array.

Returns

Arguments
Visibility
internal

Properties

Property Action IE Mozilla Netscape Opera Safari
callee : String
Name of the function being executed.
Show Details 5.5+ 1.0+ 4.0+ 7.0+ no

Example: Using arguments.callee in an anonymous recursive function

A recursive function must be able to refer to itself. Typically, a function refers to itself by its name. However, an anonymous function does not have a name, and if there is no accessible variable referring to it, i.e. the function is not assigned to any variable, the function cannot refer to itself. (Anonymous functions can be created by a function expression or the Function constructor.) This is where arguments.callee comes in.

The following example defines a function, which, in turn, defines and returns a factorial function.

function makeFactorialFunc() {
                        alert('making a factorial function!');
                        return function(x) {
                        if (x 
                        
                     
Remarks

callee is a property of the arguments local variable available within all function objects; callee as a property of Function.arguments is no longer used. (Function.arguments itself is also deprecated.)

arguments.callee allows anonymous functions to refer to themselves, which is necessary for recursive anonymous functions.

The this keyword does not refer to the currently executing function. Use the callee property to refer to a function within the function body.

Availability

JavaScript 1.2|Deprecated by JavaScript 1.4|JScript 5.5|ECMAScript v1

caller : String
Name of the function that called the function being executed.
Show Details 4.0+ 1.0 3.0+ no no

Example: Checking the value of arguments.caller in a function

The following code checks the value of arguments.caller in a function.

function myFunc() {
                        if (arguments.caller == null) {
                        return ("The function was called from the top!");
                        } else
                        return ("This function's caller was " + arguments.caller);
                        }
                        
Remarks

arguments.caller can no longer be used. Use the non-standard caller property of the function instead.

The caller property is available only within the body of a function.

If the currently executing function was invoked by the top level of a JavaScript program, the value of caller is null.

The this keyword does not refer to the currently executing function, so you must refer to functions and Function objects by name, even within the function body.

The caller property is a reference to the calling function, so:

  • If you use it in a string context, you get the result of calling functionName.toString, i.e. the decompiled canonical source form of the function.
  • You can also call the calling function, if you know what arguments it might want. Thus, a called function can call its caller without knowing the name of the particular caller, provided it knows that all of its callers have the same form and fit, and that they will not call the called function again unconditionally (which would result in infinite recursion).
Availability

JavaScript 1.2|Deprecated by JavaScript 1.3

length : Number
Number of arguments passed to the function.
Show Details 4.0+ 1.0+ 3.0+ 7.0+ 1.0+
See Also

Array.length|Function.length

Availability

JavaScript 1.1|JScript 2|ECMAScript v1

References

Function

Availability

JavaScript 1.1|JScript 2.0|ECMAScript v1

text_javascript Navioo_docs

Examples -> Source code Demo online - > arguments:

Ajax Javascript feed

↑ Grab this Headline Animator