Home  >  Article  >  Web Front-end  >  Detailed explanation of character sets in JavaScript

Detailed explanation of character sets in JavaScript

黄舟
黄舟Original
2017-10-30 09:57:411785browse

Introduction

JavaScript Programs are written using the Unicode character set. Unicode is a superset of ASCII and Latin-1 and supports almost every language in use on the planet. ECMAScript3 requires that JavaScript implementations must support Unicode2.1 and subsequent versions, and ECMAScript5 requires support of Unicode3 and subsequent versions.

Sensitivity

JavaScript is a case-sensitive language, that is, keywords, variables, functions Names and all identifiers must be in consistent case. However, it is important to note that HTML is not case-sensitive (although XHTML is case-sensitive).

Spaces, newlines and format control characters

JavaScript will ignore spaces between tokens in the program, and in most cases will also ignore newlines.

Because spaces and line breaks can be used freely in the code, neat and consistent indentation can be used to implement a unified coding style, thereby improving the readability of the code.
Space characters recognized by JavaScript:

  • Normal space characters\u0020

  • ##Horizontal tab characters\u0009

  • Vertical tab character\u000B

  • Form feed character\u000C

  • No breaking whitespace character\u00A0

  • Endian Mark\uFEFF

  • All Zs category characters in Unicode

JavaScript will The following characters are recognized as line terminators:

Line feed character\u000A

Carriage return character\u000D

Line separator\uz0z8

Paragraph separator\ u2029

The carriage return and line feed characters together are parsed into a single line terminator

Unicode escape sequence

In some computer hardware and software, the full set of Unicode characters cannot be displayed or input. For compatibility, JavaScript defines a special sequence that uses 6 ASCII characters to represent any 16-bit Unicode internal code. These Unicode escape sequences are prefixed with \u, followed by 4 hexadecimal digits (represented by digits and uppercase or lowercase letters A~F), and can be used for JavaScript literals and

regular expressions in formula and identifiers (except keywords).

The above is the detailed content of Detailed explanation of character sets in JavaScript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn