2.1 Character Set
Javascript采用Unicode编码
2.1.1 Case Sensitivity
Javascript是大小写敏感的语言
2.1.2 Whitespace, Line Breaks, and Format Control Characters
Javascript忽略空格和换行
2.1.3 Unicode Escape Sequences
由于系统和软件的关系,可能无法读取和显示整个unicode字符,为什么支持这项功能,Unicode采用一个特殊的6个字符组成的ASCII编码来表示。如:
"café" === "caf\u00e9" // => true
2.2 Comments
// This is a single-line comment.
/* This is also a comment */ // and here is another comment.
/*
* This is yet another comment.
* It has multiple lines.
*/
2.3 Literals
字面量就是直接可以在程序里面出现的
12 // The number twelve
1.2 // The number one point two
"hello world" // A string of text
'Hi' // Another string
true // A Boolean value
false // The other Boolean value
/javascript/gi // A "regular expression" literal (for pattern matching)
null // Absence of an object
2.4 Identifiers and Reserved Words
标识符和保留关键字,标识符必须以一个字母,下划线,dollar符号开头,后面可以是字母,数字,下划线,dollar符号。
2.4.1 Reserved Words
保留关键字有:
break delete function return typeof
case do if switch var
catch else in this void
continue false instanceof throw while
debugger finally new true with
default for null try
2.5 Optional Semicolons
Note that JavaScript does not treat every line break as a semicolon: it usually treats line breaks as semicolons only if it can’t parse the code without the semicolons.
Javascript将结尾看成是一个分号:只有在结尾无法形成语句的时候,才会将结尾看成是一个分号,就是后面的代码如果加进来,就会出错,那么结尾就是一个分号,不再加入后面那行代码了,有点象贪婪原则。例子:
var y = x + f
(a+b).toString()
实际的结果就是:
var y = x + f(a+b).toString();
如果第一个语句是以return break continue结尾,那么分号会自动加上,不会加入下面的句子,例如:
return
true;
JavaScript assumes you meant:
return; true;
However, you probably meant:
return true;
另一个特殊情况就是++ --的使用,它们即可以是前缀的也可以是后缀的,那么如果你想要让它们变成是后缀的,那么它们必须在一行里。例如:
x
++
y
It is parsed as x; ++y;, not as x++; y.
分享到:
相关推荐
Chapter 2 Lexical Structure Chapter 3 Types, Values, and Variables Chapter 4 Expressions and Operators Chapter 5 Statements Chapter 6 Objects Chapter 7 Arrays Chapter 8 Functions Chapter 9 Classes and...
Chapter 2 Lexical Structure Chapter 3 Types, Values, and Variables Chapter 4 Expressions and Operators Chapter 5 Statements Chapter 6 Objects Chapter 7 Arrays Chapter 8 Functions Chapter 9 Classes and...
Chapter 2 Lexical Structure Chapter 3 Types, Values, and Variables Chapter 4 Expressions and Operators Chapter 5 Statements Chapter 6 Objects Chapter 7 Arrays Chapter 8 Functions Chapter 9 Classes and...
Chapter 2. Accessing Text Corpora and Lexical Resources Chapter 3. Processing Raw Text Chapter 4. Writing Structured Programs Chapter 5. Categorizing and Tagging Words Chapter 6. Learning to Classify ...
Chapter 2: Criteria of object orientation 21 2.1 ON THE CRITERIA 21 2.2 METHOD AND LANGUAGE 22 2.3 IMPLEMENTATION AND ENVIRONMENT 31 2.4 LIBRARIES 33 2.5 FOR MORE SNEAK PREVIEW 34 2.6 BIBLIOGRAPHICAL ...
Chapter 2: Types, Operators and Expressions Variable Names Data Types and Sizes Constants Declarations Arithmetic Operators Relational and Logical Operators Type Conversions Increment and ...
Results on the structure of semantic networks such as WordNet are presented, as well as a range of similarity networks between lexical units. This chapter will surely inspire the reader to watch out ...
Lexical Structure Section 2.1. Character Set Section 2.2. Case Sensitivity Section 2.3. Whitespace and Line Breaks Section 2.4. Optional Semicolons Section 2.5. Comments Section 2.6. ...
Chapter 2—Emacs Lisp: A Short Description 2.1. GNU Emacs and Emacs Lisp 2.2. Lisp Lists 2.2.1. Parts of Lisp 2.3. Example: Two Plus Two 2.4. Evaluation 2.5. A Function Definition 2.5.1. An ...
Call by Value Character Arrays External Variables and Scope <br>Chapter 2: Types, Operators and Expressions Variable Names Data Types and Sizes Constants Declarations ...
This book begins with a quick-start tutorial to the language, and then explains the language in detail from the bottom up: from lexical and syntactic structure to datatypes to expressions and ...
Pointers to Structures and Arrays of Structure <br> 5.8 Laboratory Exercises 5.9 Programming Projects 5.10 Summary 5.11 Questions <br>Chapter Six - The 80x86 Instruction Set 6.0 ...
Chapter 2 - Types, Operators and Expressions..................... 2.1 Variable Names................................. 2.2 Data Types and Sizes........................... 2.3 Constants.................