Differences between arguments and arguments. callee in Javascript: arguments. callee
An example is provided to illustrate the differences between arguments and arguments. callee:
The Code is as follows:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function check (args ){
Var ac = args. length;
Var ex = args. callee. length;
Document. write ("ac:" + ac + '<br> ');
Document. write ("ex:" + ex + '<br> ');
If (ac! = Ex ){
Document. write ("wrong number of arguments: expected:" + ex + "; actually passed" + ac + '<br> ');
}
}
Function f (x, y, z ){
Check (arguments );
Document. write (x + y + z );
}
</Script>
Call method:
Copy codeThe Code is as follows:
<Input name = "wr" type = "button" value = "call" onclick = "f (1, 2)"/>
The running result is:
Copy codeThe Code is as follows:
Ac: 2
Ex: 3
Wrong number of arguments: expected: 3; actually passed2
NaN
My understanding:
Arguments is the object that calls this method.
Arguments. callee is the current object, which actually returns the currently executed function object.
Through this example, we can see that
Arguments actually refers to the function "f (1, 2 )"
Argument. callee actually refers to "function f (x, y, z ){}"