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

Arguments parameters in javascript functions_Basic knowledge

WBOY
Release: 2016-05-16 18:22:11
Original
809 people have browsed it

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.
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!