1. In JavaScript, the arguments object is a more specific object, which is actually a built-in property of the current function. Arguments is very similar to an array, but is not actually an array instance. Can be confirmed by the following code (of course, in the function Funcarg, the call arguments is not necessarily written funcarg.arguments, write arguments directly).
1 Array.prototype.testArg = "Test" 2 function Funcarg () { 3 alert (FUNCARG.ARGUMENTS.TESTARG); 4 alert (funcarg.arguments[0 5 6 7 alert (new Array (). Testarg); // 8 Funcarg (10); //
2. The length of the arguments object is determined by the number of arguments and not by the number of parameters. A parameter is a variable inside a function that re-opens the memory space, but it does not overlap with the arguments object memory space. In the case of arguments and values, the values are synchronous, but for one of the none, the value of this no value is not synchronized. The following code can be verified.
1 functionF (A, B, c) {2alert (arguments.length);//Result: "2"3A = 100;4Alert (arguments[0]);//Result: "5Arguments[0] = "Qqyumidi";6alert (a);//Result: "Qqyumidi"7alert (c);//result: "Undefined"8c = 2012;9Alert (arguments[2]);//result: "Undefined"Ten } One AF (1, 2);However, there is a difference between strict mode and non-strict mode:
1) Non-strict mode:
1 ! function (a) 2 {3 arguments[0] = +; 4 Console.log (a); 5 } (1); 6 // a:100
2) under strict mode:
! function (a) { // use strict mode arguments[0] = +; Console.log (a); } (1); // The arguments becomes a static copy of the parameter, regardless of a transmission, is present, does not have the binding qualitative. // output:1
3) The second case of strict mode:
! function (a) { ' use strict '; arguments[0].x=10; Console.log (a.x); } // output:10 can affect attributes
3, the function in JavaScript, the Declaration and invocation of features, you can see that the JavaScript function is not overloaded. Depending on the overloads in other languages: "The return value of the function is different or the number of parameters is different", we can draw the conclusion that: the declaration of a JavaScript function is not a return value type. Second: The number of formal parameters in JavaScript is strictly meant to facilitate the manipulation of variables in the function, and the actual arguments are already stored in the arguments object. In addition, the JavaScript function itself is a deep understanding of why a function in JavaScript cannot be overloaded: in JavaScript, a function is actually an object, a function name is a reference to a function, or the function name itself is a variable. For a function declaration and function expression as shown below, it is very helpful to understand that the function in JavaScript is not overloaded without considering the difference between function declaration and function expression.
1 functionF (a) {2 returnA + 10;3 }4 5 functionF (a) {6 returnA-10;7 }8 9 //without considering the difference between a function declaration and a function expression, it is equivalent to the followingTen One varf =function(a) { A returnA + 10; - } - the varf =function(a) { - returnA-10; -}4. There is a very useful attribute in the arguments object: callee. Arguments.callee returns the current function reference where this arguments object resides. It is recommended to use Arguments.callee instead of the function name itself when using recursive function calls. As follows:
1 function count (a) { 2 if (A==1 3 return 1; 4 5 return A + arguments.callee (--a); 6 7 8 var mm = count (10); 9 alert (mm);
Reprinted from Http://www.cnblogs.com/lwbqqyumidi/archive/2012/12/03/2799833.html
JavaScript Arguments objects