I studied the arguments in the JavaScript function a little bit at noon.
Copy Code code as follows:
<script type= "Text/javascript" >
Window.onload = function () {
(Function (arg1, arg2) {
alert (arguments.length);
alert (arguments.callee.length);
})();
}
</script>
Which observed the lower arguments.length and the Arguments.callee
First of all, arguments of course only has meaning in the function body, ARGUMENTS.LENGTH returns the number of arguments passed in the function, such as I did not pass in what, but directly run an anonymous function, then the first alert must be ' 0 ', Again, Arguments.callee returns the called function itself, and for anonymous functions, you can get a reference to it by Arguments.callee. Here Arguments.callee.length returns the number of parameters that the function is expected to pass in, so that the second alert is ' 2 ' if it is a named function, such as a function named MyTest, Then you can directly mytest.length to get the number of parameters that should be passed in.