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, which is 4, and arguments.callee.length returns the length of the parameter, only 2.
The arguments in Javascript