Arguments, callee, caller details in javascript, calleecaller
What is arguments?
When calling a function, arguments creates a similar array but not an array object, and stores the parameters actually passed to the function, it is not limited to the parameter list of function declaration.
What does Nima mean?
Write a demo. See the code below.
<! DOCTYPE html>
Run the code and use the chrome debugger to obtain
I use instanceof to judge arguments. According to the print result, arguments is an object.
Then expand the output arguments. We can see that it contains many attributes, as well as callee.
Next, we modify the above Code and pass parameters to the obj function when calling the obj function, but the obj function does not have parameters.
For specific code, see
<! DOCTYPE html>
Use the chrome debugger to obtain
As you can see, arguments contains three parameters we pass to it: "monkey", "love", and 24.
So why does arguments actually store the parameters passed to the function, rather than the declared parameters.
What is callee?
Callee is a member of the arguments object. Its value is "Function object being executed ".
What does it mean?
Let's write a demo and check the output.
The code and result are shown in the following figure.
<! DOCTYPE html>
As shown in the preceding figure, arguments. callee is a function pointing to the arguments object. Here it is obj.
What is caller?
Caller is an attribute of a function object that stores the function that calls the current function.
Note: It is called. It not only contains closures. If there is no parent function, it is null.
It's still the same. Let's keep writing a demo.
The Code is as follows:
<! DOCTYPE html>
Open the chrome debugger.
Can I understand caller in combination with code and understanding?
Articles you may be interested in:
- Example and understanding of arguments, caller, callee, call, and apply in javascript
- Js arguments, jcallee caller usage Summary
- Summary of arguments, caller, callee, and apply in js
- Js implicit parameters (arguments, callee, caller) Usage