Home > Article > Web Front-end > javascript arguments usage examples_javascript tips
3. From the declaration and calling characteristics of functions in JavaScript, it can be seen that functions in JavaScript cannot be overloaded.
According to the basis for overloading in other languages: "The function return value is different or the number of formal parameters is different", we can draw the above conclusion:
First: The declaration of a Javascript function does not have a return value type;
Second: Strictly speaking, the number of formal parameters in JavaScript is only to facilitate variable operations in functions. In fact, the actual parameters are already stored in the arguments object.
In addition, let’s deeply understand why functions in JavaScript cannot be overloaded from the JavaScript function itself: In JavaScript, functions are actually objects, and the function name is a reference to the function, or the function name itself is a variable. For the function declaration and function expression shown below, the meaning is the same as above (without considering the difference between function declaration and function expression), which is very helpful for us to understand the feature that functions in JavaScript cannot be overloaded. .
4. There is a very useful attribute in the arguments object: callee. arguments.callee returns the current function reference in which this arguments object resides. It is recommended to use arguments.callee instead of the function name itself when using recursive function calls.
is as follows: