Home  >  Article  >  Web Front-end  >  Arguments parameters in javascript functions_Basic knowledge

Arguments parameters in javascript functions_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:22:11808browse

At noon, I did a little research on the arguments in the javascript function

Copy the code The code is as follows:



Observed arguments.length and arguments.callee

First of all, arguments are of course only meaningful within the function body. arguments.length returns the number of actual parameters passed into the function. For example, I did not pass in anything here, but directly ran an anonymous function, then the first alert It must be '0'. Let's look at what arguments.callee returns is the called function itself. For anonymous functions, you can get its own reference through arguments.callee. Here arguments.callee.length returns what the function is expected to pass in. The number of parameters, in this case the second alert is '2'. If this is a named function, such as the function name is mytest, then you can directly use mytest.length to get the number of parameters that should be passed in.
Statement:
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