arguments.length represents how many parameters are actually passed to the function. This number can be larger or smaller than the formal parameter amount (the value of the formal parameter amount can be obtained through Function.length) .This article mainly shares with you the analysis of arguments.length in js. I hope it can help you.
function imagePreload() { var imgPreload = new Image(); for (i = 0; i < arguments.length; i++) { imgPreload.src = arguments[i]; } } imagePreload('001.gif', '002.gif', '003.gif', '004.gif', '005.gif')
This is the arguments in js. It is mainly used to track the input parameters.
This is like the example given by the author: the imagePreload function enters and exits 5 parameters, so
arguments.length in the js code It will know that you entered 5 parameters. And the values of the five parameters can be obtained through the indexer.
#arguments.length can get the number of parameter digits of the function.
Related recommendations:
Function name in Javascript. Usage analysis of length attribute (compare arguments.length)
The above is the detailed content of Arguments.length analysis in js. For more information, please follow other related articles on the PHP Chinese website!