Home > Article > Web Front-end > Code analysis on function parameters in JavaScript
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");
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!