Home >Web Front-end >JS Tutorial >Introduction and demonstration results of the difference between caller and callee_Basic knowledge
caller
caller returns a reference to a function that calls the current function.
Be careful when using this attribute:
1 This attribute is only useful when the function is executing
2 If in a javascript program, the function is called from the top level, null is returned
functionName.caller: functionName is currently being executed function.
If a is called directly (that is, a is called in any function, that is, a top-level call), return null:
callee
callee puts back a reference to the executing function itself, which is an attribute of arguments
Be careful when using callee:
1 This attribute is only valid when the function is executed
2 It has a length attribute, which can be used to obtain the number of formal parameters, so it can be used to compare whether the number of formal parameters and actual parameters are consistent, that is, comparison Whether arguments.length is equal to arguments.callee.length
3 It can be used to recurse anonymous functions.