Function arguments.arguments.function arguments.function arguments.function arguments.function arguments.function arguments.function arguments.function (

Parameters of a function

  • Parameters: Parameters defined by a function
  • Arguments: Arguments actually passed when the function is executed

Parameters and arguments are matched from left to right, generally in two cases

1. If the number of parameters is greater than the number of arguments, the following parameters should be set to undefined

     functionCes (a,b,c){console.log(a) //1 console.log(b) //2 console.log(c)//undefined} ces(1,2)Copy the code

The number of parameters is smaller than the number of arguments. Arguments can be accessed as arguments

function{ces2 (a) the console. The log (the arguments)} ces2 (1, 2, 3)Copy the code

You can see that you can get all the arguments passed by printing arguments

arguments

Arguments is not an array. We find that arguments have more content than our passed arguments. What are they?

callee

Callee is the function itself, and we can call callee whenever we need to call itself, for example, to find the factorial of a number

Take a chestnut

    function chen(x) {
            if (x <= 1) {
                return 1;
            } else {
                returnx * arguments.callee(x - 1); }; }; Chen (5)//120 // The specific execution of 5*4*3*2 executes itself every time, and Callee is a pointer to itselfCopy the code