arguments | NN 3 IE 4 ECMA 1 | |
Every functionwhile it is executinghas an arguments object, which is accessible as a property of the function. The object is created automatically, and cannot be created outside of the function context that owns it. For example, consider a typical function definition: function myFunc( ) { // function statements } |
||
A statement inside the function can access the arguments object by the following reference: arguments |
||
This object always contains the callee property, which is a reference to the very same function (explained in the callee property discussion). But you can also use the arguments object to access each parameter variable value through array notation. In the above example, a statement inside the myFunc( ) function can access the passed parameter value with the following reference: arguments[0] |
||
See the arguments property discussion of the Function object later in this chapter for practical applications. |
||
Properties | ||
|
||
Methods | ||
None. |
callee | NN 6 IE 5(Mac)/5.5(Win) ECMA 1 |
Read-only | |
Provides a reference to the function that created the arguments object. This property provides the essential reference to the current function, which an anonymous function would require for it to be called in a recursive construction. |
|
Example | |
myObj.doThis = function(input) { // function statements that act on parameter value if (!someCondition) { arguments.callee(input); } } |
|
Value | |
Function object reference. |
length | NN 3 IE 4 ECMA 1 |
Read-only | |
Returns the number of arguments passed to the function in its current invocation. The number is not influenced by the number of parameter variables defined for the function. |
|
Example | |
function myFunc( ) { for (var i = 0; i < arguments.length; i++) { ... } } |
|
Value | |
Integer. |