Arguments is a parameter of the currently executing function that holds the arguments that are currently called by the functions. How to use: function.arguments[i]. where function. is an option and is the name of the function that is currently executing. Arguments cannot be created, it is a parameter of the function itself and can only be used if the function starts execution. Although the use of arguments is much like an array, it is not an array. Here's a demonstration with an example:
function Argumentstest (A, b) { alert (typeof arguments);} (argumentstest);
As you can see, this is the browser window that pops up, and the arguments type is object.
function Argumentstest (A, b) { //alert (typeof arguments); alert (arguments.length);} (argumentstest);
Popup results:
function Argumentstest (A, b) { //alert (typeof arguments); alert (arguments.length); Alert (arguments[1]);} (argumentstest);
Popup Result: Note The following code:
function Argumentstest (A, b) { //alert (typeof arguments); alert (arguments.length); Alert (arguments[1]);} Argumentstest (1,2,3,4);
Popup Result: The result of the popup is 4. Here is the callee method, which returns the function object that is being executed.
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);
Popup Result: The following is the key, arguments.callee.length return how much?
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);
Popup Result: Arguments.length Returns the length of the argument, 4 , and Arguments.callee.length returned is the length of the formal parameters, only for 2.2013.8.30 today and encountered arguments, found that there are a few points to master is particularly clear. 1. First, arguments is a built-in parameter to the function object. It is a function/method in the execution process, consisting of an object passed in by the parameters, the system built-in, can be called. is independent of the arguments at the time of the function declaration (when a function declaration is not declared, it does not affect the use of arguments). 2. The overloads can be simulated according to the arguments. Specific can be seen here: http://www.w3school.com.cn/js/pro_js_functions_arguments_object.asp
Arguments learning in Javascript