1, the value of the status of the Ajax represents what 2, get post the Difference 3, how to convert the object into string 4, closure, inheritance, prototype, prototype chain 5, HTTP Transport Protocol 6, arguments is what

Source: Internet
Author: User



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); // result: "test"
8 funcArg(10);                // result: "undefined"  "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 function f(a, b, c){
 2     alert(arguments.length);   // result: "2"
 3     a = 100;
 4     alert(arguments[0]);       // result: "100"
 5     arguments[0] = "qqyumidi";
 6     alert(a);                  // result: "qqyumidi"
 7     alert(c);                  // result: "undefined"
 8     c = 2012;
 9     alert(arguments[2]);       // result: "undefined"
10 }
11 
12 f(1, 2);


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 formal parameters is different", we can draw the above conclusion:



First: The declaration of a JavaScript function is not a return value type;



Second: The number of formal parameters in JavaScript is strictly in order 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 function declarations and function expressions as shown below, it is very useful to understand that a function in JavaScript cannot be overloaded without considering the difference between a function declaration and a function expression.


1 function f (a) {
  2 return a + 10;
  3}
  4
  5 function f (a) {
  6 return a-10;
  7}
  8 
  9 // Without considering the difference between a function declaration and a function expression, it is equivalent to the following
10
11 var f = function (a) {
12 return a + 10;
13}
14
15 var f = function (a) {
16 return a-10;
17}


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);


1, the value of the status of the Ajax represents what 2, get post the Difference 3, how to convert the object into string 4, closure, inheritance, prototype, prototype chain 5, HTTP Transport Protocol 6, arguments is what


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.