If you want to add me as a friend, click the following link: hi. csdn. netinvite. php? U8943c759c7fc189ea23c1 Chapter 1 syntax this chapter introduces the syntax of the essence of JavaScript and briefly introduces its language structure. 2.1 blank spaces may be formatted characters or comments. White space is usually meaningless, but occasionally required
If you want to add me as a friend: Please click the following link http://hi.csdn.net/invite.php? U = 8943c = 759c7fc189ea23c1 Chapter 1 syntax this chapter introduces the syntax of the essence of JavaScript and briefly introduces its language structure. 2.1 blank spaces may be formatted characters or comments. White space is usually meaningless, but occasionally required
If you want to add me as a friend: Please click the following link http://hi.csdn.net/invite.php? U= 8943 & c = 759c7fc189ea23c1
Chapter 4 syntax
This chapter introduces the syntax of the essential part of JavaScript and briefly introduces its language structure.
2.1 Blank
Blank spaces may be formatted characters or comments. White spaces are usually meaningless, but occasionally need to be used to separate character sequences, otherwise they will be merged into a single symbol. For example, for the following code:
Var that = this;
Spaces between var and that cannot be removed, but other spaces can be removed.
JavaScript provides two types of Annotations: block comments enclosed by/**/and line comments starting. Annotations should be fully used to improve program readability. Note that annotations must accurately describe the code. Comments that are useless are worse than those without comments.
In the form of block annotations enclosed (Silent Voice: Short for Programming Language One. The "I" is actually the "one" of the Roman numerals. It is a kind of IBMThe third-generation advanced programming language invented in the age. In JavaScript, */may appear in the regular expression literal, so block comments are insecure for the commented block. For example:
/*
Var rm_a =/a */. match (s );
*/
A syntax error occurs. Therefore, we recommend that you do not use/**/annotation instead of // annotation.
2.2 identifier
An identifier starts with a letter and can be selectively followed by one or more letters, numbers, or underscores. The following reserved words cannot be used for identifiers:
Abstract
Boolean break byte
Case catch char class const continue
Debugger default delete do double
Else enum export extends
False final finally float for function
Goto
If implements import in instanceof int interface
Long
Native new null
Package private protected public
Return
Short static super switch synchronized
This throw throws transient true try typeof
Var volatile void
While
Most reserved words in this list are not used in this language. This list does not contain words that should be reserved but not reserved, such as undefined, NaN, and Infinity. JavaScript does not allow the use of reserved words to name variables or parameters. What's worse, JavaScript cannot use reserved words as the property name of an object in the literal volume of an object, or after the dot of an attribute access expression.
Identifiers are used for statements, variables, parameters, attribute names, operators, and tags.
2.3 digits
JavaScript has only one numeric type. It is represented as a 64-bit floating point number internally, the same as Java's double. In JavaScript, the values 1 and 1.0 are the same.
If a numeric literal has an exponential part, the value of this literal is calculated by multiplying the part before e by the power of the part after e 10. So 100 and 1e2 are the same numbers.
Negative numbers can be composed by the prefix operator.
The value NaN is a numerical value, indicating an operation result that cannot produce normal results. NaN is not equal to any value, including itself. You can use the isNaN (number) function to detect NaN.
The Infinity value indicates all values greater than 1.79769313486231570e + 308.
Digital ownership method (see chapter 1 ). JavaScript has an object Math, which contains a set of methods that act on numbers. For example, you can use the Math. floor (number) method to convert a number into an integer.
2.4 string
The string literal can be enclosed in single quotes or double quotation marks. It may contain 0 or multiple characters. /Is an escape character. When JavaScript is created, Unicode is a 16-bit character set, so all characters in JavaScript are 16-bit.
JavaScript has no character type. To represent a single character, you only need to create a string containing only one character.
Escape characters can be inserted into strings that are normally not allowed, such as backslash, quotation marks, and control characters. /U allows you to specify a digit.
"A" = "/u0041"
The string has an ength attribute. For example, "seven". length is 5.
The string is unchangeable. Once a string is created, it cannot be changed. However, it is easy to connect other strings through the + operator to obtain a new string. Two strings that contain identical characters and have the same character sequence are considered to be the same strings. Therefore:
'C' + 'A' + 'T' = 'cat'
Is true.
The string has some methods (see Chapter 8th ).
2.5 statement
A compilation unit contains a set of executable statements. In a web browser, each script JavaScript throws them together into a public global namespace. Appendix A has