JS Understanding Parameter-arguments object:
1. Parameters of the ECMAScript function:
The parameters of the ECMAScript function are internally represented by an array, which is always received by the function, regardless of the number of arguments contained in the array, or the data type of the parameter being passed in.
This parameter array can be accessed through the arguments object in the body of the function.
2. Questions about named parameters:
The named parameter in the ECMAScript function is only convenient, but is not required. In ECMAScript, the parser does not validate named parameters, but instead obtains the number of arguments by accessing the length property of the arguments object , and the arguments object is determined by the number of parameters passed in. is not determined by the number of named arguments when the function is defined.
3. Value synchronization:
The value of arguments is always synchronized with the values of the corresponding named parameters, but their memory space is independent. Named parameters that do not pass a value are automatically assigned the undefined value.
ps:<1> If only one parameter is passed in, the value of arguments[1] is not reflected in the named parameter.
All parameters in <2>ecmascript are passed as values, and arguments cannot be passed by reference.
JS Understanding Parameter-arguments Object