JavaScript Advanced Programming Note three

Source: Internet
Author: User

Chapter III Basic Concepts

The core of any language is bound to describe the basic workings of the language. This part of the content for us, reading is very boring, and even to create a sleepy, but this part of the content is important! I was fortunate enough to read the advanced programming of JavaScript, which I realized in my own work, and here are some points of note and useful things (⊙o⊙) ...

① naming rules. It is recommended to use hump naming. For example: UserName.

② block-level annotations.

1 /* 2 *  Recommended block-level comments, here to comment on the code description!  3  * /

Strict mode is used in ③javascript. In strict mode, some of the indeterminate behavior in ECMASCRIPT3 will be handled, and some unsafe operations will throw an error. Here, we can take a look at Ruan Yi Feng great god's explanation!

The statements in ④javascript are terminated with semicolons, not omitted. Although the JavaScript code is parsed, a semicolon is automatically added to the end of each sentence. When compressing code, an error occurs if the previous code statement ends without a semicolon. If we add a semicolon to the specification, JavaScript parses it without taking the time to speculate on where to insert the semicolon, which increases the performance of the code.

⑤if statements are enclosed in parentheses, although sometimes the if execution statement has only one statement that omits parentheses.

⑥return statement do not break line.

1 function Sayname () {2     var name = "Xuchaoi"; 3     return 4                name;   5 }6//  results returned undefined, when parsing JS, the system automatically adds a semicolon after return

⑦ecmascript data type: Undefined, Null, Boolean, number, String, Object. We can detect the data type of the variable by typeof, we need to pay attention to typeof (NULL)----> ' object '

After the ⑧ variable is declared, the default value is undefined.

⑨ a numeric conversion function. Number (): Applies to any data type; parseint (): string to Value; Parsefloat (): String to Value

⑩ avoid looping with a for in array.

1 var person = ["Little Red", "Xiao Ming"]; 2 person.age =; 3  for (var in person ) {4    Console.log (p); 5 // Console print out 1,2,age

? Using a label statement combined with break or continue, you can end a multilayer nested loop in the innermost loop.

? function return value specification. The function either has a return value or does not return a value. A function does not exist where there are sometimes return values, sometimes no return values.

There is a argument object in the function body (similar to an array, but not an array), it records the arguments of each incoming function, and accesses the object in the same way as an array (for example: Argument[0]).

? There is no overload in JavaScript, and a function multiple definitions will only accept the last definition.

JavaScript Advanced Programming Note three

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.