全局对象
常量属性
表示一个简单的值的全局属性。
方法属性
执行特定功能并返回结果的全局方法。
eval()uneval()isFinite()isNaN()parseFloat()parseInt()decodeURI()decodeURIComponent()encodeURI()encodeURIComponent()escape()unescape()
基本对象
基础的语言对象、方法对象和错误对象。
ObjectFunctionBooleanSymbolErrorEvalErrorInternalErrorRangeErrorReferenceErrorSyntaxErrorTypeErrorURIError
数字和日期
用于处理数字、日期和数学运算的对象。
文本处理
用于处理文本的对象。
带索引的集合
根据索引来排列的集合,类似于数组的对象。
ArrayInt8ArrayUint8ArrayUint8ClampedArrayInt16ArrayUint16ArrayInt32ArrayUint32ArrayFloat32ArrayFloat64Array
带键的集合
根据键来保存对象的集合,遍历时会根据放入的顺序。
矢量集合
SIMD 矢量数据类型可以把数据整合到一个序列中。
SIMDSIMD.Float32x4SIMD.Float64x2SIMD.Int8x16SIMD.Int16x8SIMD.Int32x4SIMD.Uint8x16SIMD.Uint16x8SIMD.Uint32x4SIMD.Bool8x16SIMD.Bool16x8SIMD.Bool32x4SIMD.Bool64x2
结构化数据
这种数据类型可以用来表示结构化数据缓存(structured data buffers)或者JSON数据,并允许与其进行交互。
控制抽象对象
反射
国际化
ECMA脚本的多语言附加组件。
非标准对象
其他
语句
对于字母顺序列表,请参阅左边的侧边栏。
控制流程
Block- 一个块语句可以用来管理零个或多个语句。该区块是由一对大括号分隔。
break- 终止当前的循环,switch,label 语句,使程序跳到下一个语句执行。
continue- 终止执行当前或标签循环的语句,直接执行下一个迭代循环。
Empty- 空语句用来表示没有语句的情况,尽管 JavaScript 语法期望有语句提供。
if...else- 如果指定的条件是 true ,则执行相匹配的一个语句,若为 false,则执行另一个语句。
switch- 计算表达式,将子句于表达式的值做匹配,执行与该值相关联的语句。
throw- 抛出一个用户自定义的异常。
try...catch- 标记一个语句块,并指定一个应该抛出异常的反馈。(Marks a block of statements to try, and specifies a response, should an exception be thrown.)
声明
函数和类
迭代器
do...while- 创建一个循环来执行语句,直到该语句条件表达式的值为false。先执行语句,再执行条件表达式,该语句至少会执行一次。
for- 创建一个由3个可选的表达式组成的循环,该循环用括号包裹,分号分割,并在循环体中执行语句。
-
for each...in - 通过指定的变量迭代对象所有属性的值。针对每个唯一的属性,会执行指定的语句块。
for...in- 无序遍历对象的可枚举属性。语句针对每个唯一的属性。
for...of- 遍历可迭代的对象 (包括arrays, 类数组对象, iterators and generators),对每个不同属性的属性,调用一个自定义的有执行语句的迭代钩子。
while- 创建一个循环语句,循环会一直持续到该语句条件表达式的值为false。先执行条件表达式,然后执行语句。
其他
debugger- 调用可用的调试功能。如果没有调试功能可用,该语句不生效。
-
export - 用来导出函数,以便这些函数能够被导入到外部模块或其他script中。
-
import - 用来引入外部的模块或另一个script中导出的函数。
label- 带标识的语句,与
break或continue语句一起使用。
-
with - 拓展一个语句的作用域。
表达式和操作符
左侧工具栏是按字母表排序的列表。
主要表达式
JavaScript中基本关键字和常用表达式。
thisthis关键字指向函数的执行上下文。functionfunction关键字定义了函数表达式。-
class class关键字定义了类表达式。-
function* function*关键字定义了一个 generator 函数表达式。-
yield - 暂停和恢复 generator 函数。
-
yield* - 委派给另外一个generator函数或可迭代的对象。
[]- 数组初始化/字面量语法。
{}- 对象初始化/字面量语法。
/ab+c/i- 正则表达式字面量语法。
-
[for (x of y) x] - Array comprehensions。
-
(for (x of y) y) - Generator comprehensions。
( )- 圆括号操作符。
-
Left-hand-side expressions
Left values are the destination of an assignment.
- Property accessors
- 成员访问可以访问对象的属性或方法
(object.propertyandobject["property"]). newnew运算符创建了构造函数实例.-
super super关键字调用父类的构造器.-
...obj - 展开运算符可以将一个可迭代的对象在函数调用的位置展开成为多个参数,或者在数组字面量中展开成多个数组元素。
-
自增运算和自减运算
前置/后置自增运算符和前置/后置自减运算符.
A++- 后置自增运算符.
A--- 后置自减运算符.
++A- 前置自增运算符.
--A- 前置自减运算符.
-
一元运算符
一元运算符只有一个操作数.
deletedelete运算符用来删除对象的属性.voidvoid运算符表示表达式放弃返回值.typeoftypeof运算符用来判断给定对象的类型.+- 一元加运算符将操作转换为Number类型.
-- 一元减运算符将操作转换为Number类型并取反.
~- 按位非运算符.
!- 逻辑非运算符.
-
Arithmetic operators
Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.
+- 加法运算符.
-- 减法运算符.
/- 除法运算符.
*- 乘法运算符.
%- 取模运算符.
-
关系运算符
A comparison operator compares its operands and returns a
Booleanvalue based on whether the comparison is true. inin运算符用来判断对象是否拥有给定属性.instanceofinstanceof运算符判断一个对象是否是另一个对象的实例.<- 小于运算符
>- 大于运算符.
<=- 小于等于运算符.
>=- 大于等于运算符.
-
相等操作符
The result of evaluating an equality operator is always of type
Booleanbased on whether the comparison is true. ==- 相等 运算符.
!=- 不等 运算符.
===- 全等 运算符.
!==- 非全等 运算符.
-
位移运算符
Operations to shift all bits of the operand.
<<- Bitwise left shift operator.
>>- Bitwise right shift operator.
>>>- Bitwise unsigned right shift operator.
-
二元按位运算符
Bitwise operators treat their operands as a set of 32 bits (zeros and ones) and return standard JavaScript numerical values.
&- Bitwise AND.
|- Bitwise OR.
^- Bitwise XOR.
-
二元逻辑运算符
逻辑运算符是典型的使用boolean(逻辑)值, and when they are, they return a boolean value.
&&- 逻辑与.
||- 逻辑或.
-
Conditional (ternary) operator
(condition ? ifTrue : ifFalse)-
The conditional operator returns one of two values based on the logical value of the condition.
-
Assignment operators
An assignment operator assigns a value to its left operand based on the value of its right operand.
=- Assignment operator.
*=- Multiplication assignment.
/=- Division assignment.
%=- Remainder assignment.
+=- Addition assignment.
-=- Subtraction assignment
<<=- Left shift assignment.
>>=- Right shift assignment.
>>>=- Unsigned right shift assignment.
&=- Bitwise AND assignment.
^=- Bitwise XOR assignment.
|=- Bitwise OR assignment.
-
[a, b] = [1, 2]
{a, b} = {a:1, b:2} -
Destructuring assignment allows you to assign the properties of an array or object to variables using syntax that looks similar to array or object literals.
-
逗号操作符
,- The comma operator allows multiple expressions to be evaluated in a single statement and returns the result of the last expression.
-
非标准化特性
- Legacy generator function
- The
functionkeyword can be used to define a legacy generator function inside an expression. To make the function a legacy generator, the function body should contains at least oneyieldexpression. - Expression closures
- The expression closure syntax is a shorthand for writing simple function.
-
规范
规范 状态 说明 ECMAScript 1st Edition. Standard Initial definition. ECMAScript 5.1 (ECMA-262)
ExpressionsStandard ECMAScript 2015 (6th Edition, ECMA-262)
ECMAScript Language: ExpressionsStandard New: Spread operator, destructuring assignment, superkeyword, Array comprehensions, Generator comprehensions相关链接
运算符优先级
函数
本章介绍如何使用 JavaScript函数 来开发应用程序。
