Home > Web Front-end > JS Tutorial > body text

Arguments.length analysis in js

小云云
Release: 2018-03-08 16:16:13
Original
1978 people have browsed it

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(&#39;001.gif&#39;, &#39;002.gif&#39;, &#39;003.gif&#39;, &#39;004.gif&#39;, &#39;005.gif&#39;)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!