In the function body, the identifier arguments is an application that points to the real parameter object, and the real parameter object is an array object, so that you can access the real parameter value of the input function through the numerical subscript,
Demonstrate arguments usage
View code
// Query the maximum function Maxs () {VaR _ max = number. negative_infinity; // negative infinity. This value is returned when overflow occurs. // The system traverses the real parameters and searches for and records the maximum value for (VAR I = 0; I <arguments. length; I ++) {If (arguments [I]> _ max) {_ max = arguments [I] ;}return _ max ;}var largest = Maxs, 4,10, 3,0, 33,44); console. log (largest); console. log ("************************************* ********************************"); function f (x) {console. log (x); arguments [0] = NULL; console. log (x); console. log ("arguments length:" + arguments. length); // actual parameter console. log ("Expected parameter count:" + arguments. callee. length);} f (1 );
The most suitable application scenario for argument [] objects is when a function contains a fixed number of required parameters for naming, and optional parameters with a variable number. Arguments is not a real array.