Basic syntax for JavaScript
What are the basic syntax requirements for JavaScript? Let me introduce you to the following:
1.javascript Order of execution
Follow the order in the HTML file in sequence.
2. Case-sensitive
JavaScript distinguishes between character case, two strings of the same case, and will be considered different strings. In addition, JavaScript keyword is also case-sensitive, to strictly follow the syntax required to write.
3. Writing format
JavaScript ignores whitespace and line breaks, to use ; to end a statement. It can write multiple statements in one line, the last line of the semicolon class can be omitted but try not to omit. In order to improve the readability of the program, we should use these formats, which is a clearer and more readable change to the program.
4. Comment statements
In order to improve the maintainability and readability of the program, there should be some comment statements. He reads it to the programmer and, of course, it is to prevent you from looking back at these statements to remember what he used to do. A single-line comment is usually started by//. Multi-line comments are commented by/* */.
1 //I am a single-line comment 2 /* 3 I am a multiline note 4 I am a multiline comment 5 */
Reserved words in 5.javascript
JavaScript retains a subset of the words used for specialized purposes, which we call reserved words. Reserved words cannot be used for naming constants, functions, and so on. There are some special words that we cannot use to name in order to avoid ambiguity. Here is the reserved word for JavaScript.
Error in 6.javascript
(1) syntax error: Debug via console.
(2) Logic error: Debug error via alert () popup box.
7.javascript 4 ways to get HTML tags
Get ID
1 document.getElementById (' id ')
Get class
1 document.getelementsbyclassname (' class ')
Get tag Name
1 document.getelementstagname (' tag name ')
Get Name
1 document.getelementsname (' name ')
Basic syntax for JavaScript