The parameters of the JS function can be obtained in the function using the arguments object.
There are two ways to call parameters:
1. Use of desired parameters.
2. Use of actual passed parameters.
Application example:
function Test(a, b){var i, s = "Test function has";var numargs = arguments.length; // Get the numeric value of the actually passed parameter. var expargs = Test.length; // Get the value of the expected parameter, the number of expected parameters when the function is defined (there are 2 parameters a and b). s += (expargs + "parameters.");s += "/n/n" for (i =0 ; i < numargs; i++){ // Get the parameter content. s += "" + i + " parameters are: " + arguments[i] + "/n";}return(s); // Return to the parameter list. }alert(Test('param1','second param','third parameter'));What should be noted is:
arguments is an object object, it is not an array, and you cannot use shift, push, join and other methods on it.
The i in arguments[i] used in the above example is only an attribute of the arguments object and cannot be understood as an array subscript.
Code Demo
<html><head> <script language="javascript"> function reloadList(){ if(typeof arguments[0] == "function"){ arguments[0].call(this);arguments[0]();} if(typeof arguments[0] == "string") alert(arguments[0]); if(typeof arguments[0] == "number") alert(arguments[0]); if(typeof arguments[0] == "undefined") alert(arguments[0]); if(typeof arguments[0] == "undefined") alert(arguments[0]); if(typeof arguments[0] == "undefined") alert(arguments[0]); if(typeof arguments[0] == "undefined") alert(arguments[0]); if(typeof arguments[0] == "undefined") alert(arguments[0]); if(typeof arguments[0] arguments[0] == "boolean") alert(arguments[0]);if(typeof arguments[0] == "null") alert(arguments[0]); }reloadList(function(){});</script></head><body></body>The above article in-depth understanding of the use of JS functions parameters is all the content I have shared with you. I hope it can give you a reference and I hope you can support Wulin.com more.