This article mainly introduces the use of arguments and jcalleecaller in js. For more information, see arguments, callee, and caller.
Arguments: parameters of the Input Function
Callee: the statement that represents the function and the function body.
Caller: indicates the function that calls this function.
Arguments
This object represents the function being executed and the parameters of the function that calls it.
Caller
Returns a reference to the function that calls the current function.
FunctionName. caller
The functionName object is the name of the executed function.
Description
For a function, the caller attribute is defined only when the function is executed. If the function is called by the top layer, caller contains null. If the caller attribute is used in the string context, the result is the same as functionName. toString, that is, the decompilation Text of the function is displayed.
Callee
Returns the Function object being executed, that is, the body of the specified Function object.
[Function.] arguments. callee
The optional function parameter is the name of the currently executed Function object.
Description
The initial value of the callee attribute is the Function object being executed.
The callee attribute is a member of the arguments object. It indicates a reference to the function object itself. This facilitates recursion of anonymous functions or ensures function encapsulation, for example, the following example recursively calculates the sum of natural numbers from 1 to n. This attribute is only available when the related function is being executed. It should also be noted that callee has the length attribute, which is sometimes used for verification. Arguments. length is the length of the real parameter, and arguments. callee. length is the length of the form parameter, which can be used to determine whether the length of the form parameter is consistent with the actual length.
The Code is as follows: