Arguments.callee
Arguments’ main use is to hold function arguments. This object has a property called Callee, which is a pointer to the function that has the arguments object.
- The following factorial function uses a recursive algorithm, which requires the function to call itself. The optimized writing method is more flexible. If we want to change the function name, we do not need to look inside the function
function factorial(num){ if (num <=1) { return 1; } else {// The execution of this function is closely coupled to the name of factorial, which is not good. Return factorial(num-1)}} function factorial(num){if (num <=1) {return 1; Return num * arguments.callee(num-1)} else {return num * arguments.callee(num-1)}}Copy the code