since the JS call function can not be in accordance with the function of the definition format to pass parameters, for example:
function Test (A, b) {do something}
Test (1);
Test (from);
Test ();
The above three call methods are correct, but if the test function uses a A, b parameter, the test () Call function may return a undefined error . So JS provides a keyword arguments to get the parameters passed in. Arguments is an array with the Length property, which can be obtained by arguments[index] to get the parameter values passed in by the function.
For example:
function addition (A, b) { return a+b;//if a, B is not passed in will be an error! }//Improved Method Funciton Additionbetter (A, b) { if (arguments.length==0) return 0; else if (arguments.length==1) { return arguments[0]; } else{ return arguments[0]+arguments[1];} }
Usage of arguments keywords in javascript