Arguments is a parameter of the function currently being executed. It stores the parameters currently called by the function. Arguments is a parameter of the function currently being executed. It stores the parameters currently called by the function.
Usage: function. arguments [I].
Function is optional and the name of the function currently being executed.
Arguments cannot be created. It is a function parameter and can only be used when the function is executed.
Although the use of arguments is similar to an array, it is not an array.
The following is an example:
function argumentsTest (a,b) { alert(typeof arguments);}argumentsTest(1,2);
As you can see, this is displayed in the browser window. The arguments type is object.
function argumentsTest (a,b) { // alert(typeof arguments); alert(arguments.length);}argumentsTest(1,2);
Pop-up results:
function argumentsTest (a,b) { // alert(typeof arguments); // alert(arguments.length); alert(arguments[1]);}argumentsTest(1,2);
Pop-up results:
Note the following code:
function argumentsTest (a,b) { // alert(typeof arguments); alert(arguments.length); // alert(arguments[1]);}argumentsTest(1,2,3,4);
Pop-up results:
The pop-up result is 4.
The following is the function object that is being executed in the callee method.
function argumentsTest (a,b) { // alert(typeof arguments); // alert(arguments.length); // alert(arguments[1]); alert(arguments.callee); // alert(arguments.callee.length);}argumentsTest(1,2,3,4);
Pop-up results:
The following is the key. What is returned by arguments. callee. length?
function argumentsTest (a,b) { // alert(typeof arguments); // alert(arguments.length); // alert(arguments[1]); //alert(arguments.callee); alert(arguments.callee.length);}argumentsTest(1,2,3,4);
Pop-up results:
It can be seen that arguments. length returns the length of the real parameter, which is 4; while arguments. callee. length returns the length of the form parameter, which is only 2.