Chapter 2 JavaScript lexical structure

Source: Internet
Author: User

ProgramThe lexical structure of the design language is a set of basic rules used to describe how to use this language to write programs. It is the lowest-level syntax of a language, specifying the variable name, the description of what characters should be used, and how to separate statements.

1. Character Set:

Javascript program is usedUnicodeCharacter Set. And7-bit ASCII code(Only for English) and8-bit ISO Latin-1 encoding(Only applicable to English and Western European languages) Different, 16-bit Unicode encoding can represent every written language commonly used on the earth.

Programmers in the United States and other English-speaking countries usually use text editors that only support ASCII code and Latin-1 encoding, making it difficult for them to access the complete Unicode Character Set. But this is not a problem, because both the ASCII encoding and Latin-1 encoding are the subset of Unicode encoding, so the javascript programs written in these two encoding sets are absolutely effective. Each character in a javascript program is expressed in two bytes.

2. Case Sensitive:

Javascript is a case-sensitive language. This means that keywords, variables, function names, and all identifiers of the input language must be in the same case.

3. Blank and line breaks:

Javascript ignores spaces, tabs, and line breaks between marks in the program. Therefore, you can freely arrange the program structure and use indentationCodeIt is easier to read and understand. However, note that there is a slight restriction on the placement of line breaks, which will not be described later (see the rhino p24 for details ).

4. Optional semicolon:

Simple statements in Javascript usually have semicolons (;), which are mainly used to separate the statements. This is the same as C, C ++, and Java. However, if the statements in JavaScript are placed in different rows, the semicolon can be omitted. Skipping semicolons is not a good programming habit.

5. Notes:

Javascript supports two types of Annotations: the first is a single line comment //, and the second is a multi-line comment/* Comment */.

6. Direct Volume:

The so-called direct volume is the data value directly displayed in the program. The following lists the direct quantities:

 
121.2 "Hello World" 'Hi' truefalsenull/JavaScript/GI // Regular Expression

In ecmascript V3, expressions such as array direct volume and object direct volume are also supported. For example:

 
[1, 2, 3, 4, 5] {X: 1, Y: 2}

Directly speaking is an important part of any programming language, because it is almost impossible to compile a program without a direct amount.

7. identifier:

An identifier is a name. In JavaScript, identifiers are used to name variables and functions, or as tags for certain loops in JavaScript code. Legal identifier naming rules in javascript: the first character must be a letter, underline, or dollar sign $. The following characters can be letters, numbers, underscores, or dollar signs. Note that numbers cannot appear as the first character.

Finally, the identifier cannot have the same name as the keyword in JavaScript.

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.