The third chapter of the advanced programming of JavaScript

Source: Internet
Author: User

The third chapter of the advanced programming of JavaScript mainly describes the basic concept of the language, the content is many and shallow, through the mind map can help us to clarify the context.

The JS function uses the function keyword to declare, here is a simple example:

1     function Sayhi (name, message) {2        alert ("Hello," +name + message); 3     }

The return statement can be used in a function to specify the returned value, and if only "return;" The function will return undefined after it has stopped executing;

The function defined has 2 parameters, so when calling this function, it is not necessary to pass two parameters: 1, 2, 3 ... Or not pass it all-because the ECMAScript parameter is internally represented by an array, and a named parameter that does not pass the value is automatically given the value of undefined; in the body of the function, the array of arguments can be accessed by arguments objects:

1     function Doadd (NUM1, num2) {2         if (Arguments.length = = 1) {3             alert (NUM1 +); 4         } Else if (Arguments.length = = 2) {5             alert (arguments[0] +); 6         }7     }

With regard to the behavior of arguments, its value is always synchronized with the corresponding named parameter, but this does not mean that the two values will access the same space, their memory space is independent, but their values will be synchronized:

1     function Doadd (NUM1, num2) {2         // overriding the second parameter is ten 3         // the value of the num2 is ten 4     }

ECMAScript defined functions cannot be overloaded because they do not have function signatures (function signatures: function declaration information, including: parameters, return values, calling conventions, etc.).

The third chapter of the advanced programming of JavaScript

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.