Callee
Callee is a property of an object that is a pointer to a function of a parameter arguments object
Let's start by writing a step function:
function Chen (x) {
if (x<=1) {return
1;
} else{return
x*chen (x-1)
;;};
From this function can be seen that the use of recursive functions, if the change in the function name, the function name inside also change, so it is inconvenient so we use callee to try
function Chen (x) {
if (x<=1) {return 1;
} else{return
X*arguments.callee (x-1);
};
Let's analyze why we write this: according to the definition of callee, we can see that callee is a property of the arguments object, a function that points to the arguments object, this function is Chen (Chen=arguments.callee), This explanation should be understandable.
Caller
Caller is a property of a function object that holds a reference to the function that invokes the current function (pointing to the immediate parent function of the current function)
Let's start with an example.
function A () {
B ();
};
Function B () {
alert (b.caller);
};
A (); The result is pop-up function A and content
Let's explain, first of all, function B's property caller the function that calls the current function B refers to a (that is, a parent function of the current function B), so the result is a pop-up function a () {B ();};
So understand caller and callee, then you can not combine the two together to use it
Function B () {
alert (b.caller);
};
We can see from this code that the B function name is called in the B function, so it's inconvenient when the function name changes, we need to replace that B inside.
Before we know what method to point to the current object, we will modify the following:
(function A () {
B ();
}) ();
Function B () {
alert (arguments.callee.caller);
};
We can see from the code that we replaced the B function with Arguments.callee, so we solved the problem ...
The above mentioned is the entire content of this article, I hope you can enjoy.