Inserted only before, after one or more line breaks, and at the end of program inputThis means that you can only omit semicolons in a row, a block of code, and where a program ends.Which means you can write code like this.function Square (x) { var n = +x return n * n}But it can't be written like the code below, so it's an error.function Area (r) { r = +r return math.pi*r*r}//errorInserted only when subsequent input tags cannot be resolvedIn other words,
First, prefaceTonight in the eyes of the people to see the front-end technical experts-He Shijun on the JavaScript sentence should be added semicolon? "The answer, let me once again see Daniel's style, really admire extremely." But pure admiration is not enough to repay him such excellent words, must understand the meaning of the text and the principle behind it deserves it!Prior to this we need to understand the ASI (automatic
JS magic Hall: ASI (automatic semicolon insertion mechanism) and Front semicolonI. Preface I will see the frontend Technical Expert of the People's Network in zhihu tonight-He Shijun-should I add points to JavaScript statements? The answer, let me once again see the elegant style of Daniel, really admire. However, the Pure admiration is not enough to return to such excellent texts. It is worthy of understanding the meaning of the texts and the princip
Look at the code:
Html:
Copy Code code as follows:
Index.js content:
Copy Code code as follows:
/*
Author:binarytree
*/
Fill a local reference to a picture
Ext.blank_image_url = ' resources/images/default/s.gif ';
Name space
Ext.namespace (' MyNamespace ');
Creating an Application
Mynamespace.app = function ()
{
Return
{
Init:function ()
{
Alert (' Initialization of program completed ');
}
};
}();
Online index, wai
When reading Extjs Chinese manual today, I wrote four or five lines of sample code. As a result, IE and Firefox failed to report an error.
Check the Code:
HTML:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 2 3 4 5 6 7
8
9
10
13 14
15 16 17 18 19 20 21 22
Index. js content:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->1 /*
2 Author: binarytree
3 */
4 // fill in the local reference
Check the Code:
HTML:
Copy codeThe Code is as follows:
Index. js content:Copy codeThe Code is as follows :/*Author: binarytree*/// Fill in the local reference of the imageExt. BLANK_IMAGE_URL = 'resources/images/default/s.gif ';// NamespaceExt. namespace ('mynamespace ');// Create an applicationMyNameSpace. app = function (){Return{Init: function (){Alert ('program initialization completed ');}};}();
The following results are indexed on the Internet: ECMAScript stipulates that in some cases,
[Note] JavaScript coding specifications-comma and semicolon, and javascript semicolon
Do not use a comma before a statement.
// Badvar story = [once, upon, aTime]; // goodvar story = [once, upon, aTime];
Do not include extra commas: this will cause some problems in the weird modes of IE6, IE7, and IE9. At the same time, in some implementations of ES3, extra commas will increase the length of the array.
JavaScript Each statement ends with a semicolon, but because JavaScript has a semicolon automatic insertion rule, all the different programmers have different habits, some with a semicolon, and some without a semicolon, then whether to add a semicolon or no
Optional semi-colonAs in some languages,, JSusing semicolons(;)separate the statements.This is important to enhance the readability and cleanliness of your code.:missing delimiter,The end of a statement is the next statement,you seem to be talking to someone on the walkie-talkie.,I didn't finish a word.,have to say Oversame,It means you're done..in theJSin,if the statements are exclusive to each row,patency can omit a semicolon between statements.many
Text: The semicolon insertion mechanism in JavaScriptInserted only before, after one or more line breaks, and at the end of program inputThis means that you can only omit semicolons in a row, a block of code, and where a program ends.Which means you can write code like this.function Square (x) { var n = +x return n * n}But it can't be written like the code below, so it's an error.function Area (r) { r = +r return math.pi*r*r}//errorInserte
Objective
Trust in C # and Java everyone knows that the semicolon is used as a punctuation (eos,end of statement), and must be semicolon, otherwise the compilation will not pass. But JavaScript has an ASI mechanism that allows us to omit semicolons. ASI mechanism is not to say that in the parsing process, the parser automatically adds a semicolon to the code, bu
The semicolon of the JavaScript represents the terminator of the statement, but since JavaScript has a semicolon-inserted rule, it is a very confusing thing, and in general, a line break produces a semicolon, but the reality is not , which means that wrapping in JavaScript can produce a semicolon or not, or whether to
Inserted only before, after one or more line breaks, and at the end of program inputThis means that you can only omit semicolons in a row, a block of code, and where a program ends.Which means you can write code like this.function Square (x) { var n = +x return n * n}But it can't be written like the code below, so it's an error.function Area (r) { r = +r return math.pi*r*r}//errorInserted only when subsequent input tags cannot be resolvedIn other words,
The semicolon of JavaScript represents the terminator of the statement, but because JavaScript has a semicolon-inserted rule, it is a very confusing thing, and in general, a newline produces a semicolon, but the reality is not , which means that wrapping in JavaScript can result in a semicolon or not, and whether to au
A detailed description of the semicolon Insertion Mechanism in JavaScript
This article mainly introduces the semicolon Insertion Mechanism in JavaScript. This article describes the semicolon Insertion Mechanism in various cases in JavaScript. For more information, see
Inserted only before}, after one or more line breaks, and end of program input
That is to say,
Learning Notes is primarily about documenting some of the things JavaScript needs to pay attention to, and some small details.Optional semi-colonLike many other programming languages, JavaScript uses semicolons (;) separate statements. This is important for enhancing the readability and cleanliness of your code.Without a delimiter, the end of a statement is the beginning of the next-hop statement, and vice versa.In JavaScript, if the statement is a single line, you can usually omit the
It is entirely up to your personal habits to add and not add semicolons, but it is recommended to use semicolons for code stability (parsing errors).JavaScript auto-semicolon rule:1. When there are newline characters (including multiline comments with line breaks), and the next token cannot match the previous syntax, the semicolon is automatically complement.2. When there is a
The semicolon in Javascript indicates the end character of the statement. However, because JavaScript has a semicolon automatic insertion rule, some people think that it is not necessary to write the statement. In general, A line feed produces a semicolon, but this may not be the case. That is to say, a line feed in Javascript may generate a
statements in ECMAScript is terminated by a semicolon, though omitting the semicolon makesThe parser determine where the end of a statement occurs, as in the following examples:var sum = a + b //valid even without a semicolon-not recommendedvar diff = b; Valid-preferredeven though a semicolon is no required a
In the old version of Kmdjs, the requirement for semicolons was enforced. But always feel uncomfortable, because in the development of Ket-kmdjs Extension tools, always need to import some open source Library, and then the pain came, always error, a check, is missing semicolon!! Later, you can JSLint can detect where the semicolon is missing, then you can use JSLint in the missing place to add a
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.