argumentsfunctionsay (num) {/*there is a property called arguments in the function object, which can be used to obtain the corresponding parameter value, which is an array, which is actually the parameter passed in.*/Console.log (arguments.length); for(vari=0;i<arguments.length;i++) {Console.log (arguments[i]); } console.log (num);}/*in arguments This object has a callee method, Arguments.callee (ARG) can reverse the call*///say (a);//This is coupled with the function name//return num * factorial (num-1);//The following is the implementation of the function name of the decoupling, in JS is usually used in this way to do recursionfunctionfactorial (num) {if(num<=1){ return1; }Else{ returnNum*arguments.callee (num-1); }}/*The above is a function of factorial, the function name of the recursive call and the original function name are coupled together if the function name changes in the future after the recursive call will be invalidated*/varCF =factorial;//no error at this timeConsole.log (CF (5)); factorial=NULL;//at this point, because the CF function is still called with the name factorial, but Factorial has pointed to null, so it will be an error//recursive calls are invalidatedConsole.log (CF (5)); This
/*when a class needs to be created, the properties and methods of the set class need to be referenced by the This keyword, but it is particularly important to note that the This keyword will be different when called by different harmonic objects*/varcolor = ' Red ';functionShowcolor () {Console.log ( This. color);}//created a class that has a color property and a Show methodfunctionCircle (color) { This. color =color; This. Showcolor =Showcolor;}varc =NewCircle (' Yellow ');//using C to call the Showcolor method is equivalent to calling the Showcolor () method//This is C, so color is yellowC.showcolor ();//Yellow//the object called at this time, and so window,showcolor this is the window, so you will find the window colorShowcolor ();//Red
The function deeply understands the internal properties of the---function arguments and this