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

Code analysis on function parameters in JavaScript

黄舟
Release: 2017-10-27 09:37:05
Original
1341 people have browsed it

When writing a function in js, its parameters are internally represented as an array. That is to say: when we define a function, the parameters inside have nothing to do with the actual parameters passed in when calling this function in the future. If we want to define a function functionName(){}, the function itself has no parameters when it is defined. Yes, but we can pass in many parameters when calling this parameter, and inside the function, we can use the object of arguments to access the parameters:

function funcName() {
    for (var  item=0 ;item< arguments.length;item++) {
        console.log(arguments[item]);
    }
}
funcName("first", "second");
Copy after login

The above is the detailed content of Code analysis on function parameters in JavaScript. 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