Home > Web Front-end > JS Tutorial > Detailed explanation of the basic syntax requirements of JavaScript language_Basic knowledge

Detailed explanation of the basic syntax requirements of JavaScript language_Basic knowledge

WBOY
Release: 2016-05-16 15:31:06
Original
1519 people have browsed it

What are the basic grammatical requirements of JavaScript language? The following will give you the answers one by one:

1. Case sensitive
                                                                                                                                                                                               JavaScript language distinguishes characters between uppercase and lowercase characters, and two strings with the same case but different cases are considered to be different strings. JavaScript language keywords are also case-sensitive and should be lowercase according to grammatical requirements. 2. Writing format
JavaScript Language ignores the gap between words, that is, the space between the sentences, the empty line, the indentation, etc.
In order to improve the readability of the program, these formats should be used to make the program clearer and more readable. 3. Comment statements
In order to improve the maintainability and readability of the program, there should be certain comment statements.
It is for people who read the program. There are single-line comments and multi-line comments. Single-line comments Comments start with a double slash, and multiple lines start and end with /*,*/.

<script type="text/javascript">//JavaScript代码放置的位置(单行注释) 
 function theAlert(textToAlert) { 
 alert(textToAlert); 
 } 
 /* 
 定义一个名字叫theAlert的函数,此函数带一个参数textToAlert。 
 函数体内调用JavaScript语言的内部函数alert()输出参数。(多行注释或块注释) 
 */ 
 theAlert("Hello World");//调用定义的函数输出参数 
 </script> 
Copy after login
4. Use of semicolons

The statements in the javascript language ends in the segment.
Some codes, such as loop structures or conditional statements of selection structures, do not need to be followed by a semicolon, otherwise the execution path of the original structure will be changed. For example: if(a==1): After adding a semicolon, the content after the conditional statement will be executed regardless of whether the value of a is 1, and the conditional test fails. 5. Where to place JavaScript
JavaScript code can be placed in the tag in the HTML page, or it can be placed in the tag, in the

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template