Chapter Two: JavaScript lexical structure

Source: Internet
Author: User

The lexical structure of a programming language is a set of basic rules that describe how you write the language. As the basis of the syntax, it specifies what the variable name is, how to write the comment, and how the statements are differentiated. This is a short space to introduce the lexical structure of JavaScript.

1. Character Set

JavaScript programs are written in the Unicode character set, Unicode is a superset of ASCII and Latin-1, and supports almost all languages in the region. ECMASCRIPT3 requires JavaScript implementations to support unicode2,1 and subsequent versions, ECMASCRIPT5 requires support for UNICODE3 and subsequent versions

I. Case-sensitive

JavaScript is a case-sensitive language, meaning that keywords, variables, function names, and all expression characters must be in a consistent case, such as when the keyword while must be written while, cannot be written as while or while.

However, it is important to note that HTML is not case-sensitive (despite the XHTML distinction), and because it is closely related to client-side JavaScript, it is easy to confuse. For example, in processing events for HTML settings, the onclick attribute can be written as an onclick, but in JavaScript it is written as a lowercase onclick.

II Space, line break, and format controller

JavaScript ignores spaces between tokens in the program, and in most cases, JavaScript ignores line breaks. Because you can freely use spaces and line breaks in your code, you can make your code more readable by using neat and consistent indentation to form a unified coding style.

JavaScript is in addition to identifying whitespace (\u0020). JavaScript also shibiao characters that indicate spaces: Horizontal tab (\u0009), Vertical tab (\u000b), page break (\u000c), non-disruptive whitespace (\u00a0), byte-order mark (\ufeff), and the characters in all ZS categories in Unicode. JavaScript recognizes the following characters as Terminators: line Break (\u000a), carriage return (\u000d), line delimiter (\u2028), segment Separator (\u2029). Carriage return multibyte a newline character together. Resolves to a single-line terminator.

(not to be continued)

Chapter Two: JavaScript lexical structure

Related Article

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.