This chapter documents all the JavaScript language operators, expressions and keywords.

表达式和运算符 (按类别)

对于按字母顺序清单,请参阅左侧边栏。

首要表达式

JavaScript 中的基本关键字和通用表达式。

this
this 关键字引用执行上下文特殊特性。
function
function 关键字定义函数表达式。
class
class 关键字定义类表达式。
function*
function* keyword defines a generator function expression.
yield

Pause and resume a generator function.

yield*

Delegate to another generator function or iterable object.

async function
async function defines an async function expression.
await

Pause and resume an async function and wait for the promise's resolution/rejection.

[]

Array initializer/literal syntax.

{}

Object initializer/literal syntax.

/ab+c/i

Regular expression literal syntax.

( )

Grouping operator.

左手侧表达式

Left values are the destination of an assignment.

特性访问器
Member operators provide access to a property or method of an object
( object.property and object["property"] ).
new
new operator creates an instance of a constructor.
new.target
In constructors, new.target refers to the constructor that was invoked by new .
super
super keyword calls the parent constructor.
...obj

Spread syntax allows an expression to be expanded in places where multiple arguments (for function calls) or multiple elements (for array literals) are expected.

递增和递减

Postfix/prefix increment and postfix/prefix decrement operators.

A++

后缀递增运算符。

A--

后缀递减运算符。

++A

前缀递增运算符。

--A

前缀递减运算符。

一元运算符

A unary operation is operation with only one operand.

delete
delete operator deletes a property from an object.
void
void 运算符丢弃表达式的返回值。
typeof
typeof operator determines the type of a given object.
+

The unary plus operator converts its operand to Number type.

-

The unary negation operator converts its operand to Number type and then negates it.

~

按位 NOT 运算符。

!

逻辑 NOT 运算符。

算术运算符

Arithmetic operators take numerical values (either literals or variables) as their operands and return a single numerical value.

+

Addition operator.

-

Subtraction operator.

/

Division operator.

*

Multiplication operator.

%

Remainder operator.

**

Exponentiation operator.

关系运算符

A comparison operator compares its operands and returns a 布尔 value based on whether the comparison is true.

in
in operator determines whether an object has a given property.
instanceof
instanceof operator determines whether an object is an instance of another object.
<

小于运算符。

>

Greater than operator.

<=

Less than or equal operator.

>=

Greater than or equal operator.

Note: => is not an operator, but the notation for 箭头函数 .

相等运算符

The result of evaluating an equality operator is always of type 布尔 based on whether the comparison is true.

==

相等运算符。

!=

Inequality operator.

===

Identity operator.

!==

Nonidentity operator.

按位移位运算符

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.

&

按位 AND。

|

按位 OR。

^

按位 XOR。

二进制逻辑运算符

Logical operators are typically used with boolean (logical) values, and when they are, they return a boolean value.

&&

逻辑 AND。

||

逻辑 OR。

条件 (三元) 运算符

(condition ? ifTrue : ifFalse)

The conditional operator returns one of two values based on the logical value of the condition.

赋值运算符

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.

&&=

Logical AND assignment.

||=

Logical OR assignment.

??=

Logical nullish 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.

规范

规范
ECMAScript (ECMA-262)
在该规范中的 ECMAScript Language: Expressions 定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
Addition ( + ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Addition assignment ( x += y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Assignment ( x = y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
async function expression Chrome 55 Edge 15 Firefox 52 IE No Opera 42 Safari 10.1 WebView Android 55 Chrome Android 55 Firefox Android 52 Opera Android 42 Safari iOS 10.3 Samsung Internet Android 6.0 nodejs 7.6.0
7.6.0
7.0.0 Disabled
Disabled From version 7.0.0: this feature is behind the --harmony runtime flag.
await Chrome 55 Edge 14 Firefox 52 IE No Opera 42 Safari 10.1 WebView Android 55 Chrome Android 55 Firefox Android 52 Opera Android 42 Safari iOS 10.3 Samsung Internet Android 6.0 nodejs 7.6.0
7.6.0
7.0.0 Disabled
Disabled From version 7.0.0: this feature is behind the --harmony runtime flag.
Bitwise AND ( a & b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise AND assignment ( x &= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise NOT ( ~a ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise OR ( a | b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise OR assignment ( x |= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise XOR ( a ^ b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise XOR assignment ( x ^= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
class Chrome 42 Edge 13 Firefox 45 IE No Opera 29 Safari 7 WebView Android 42 Chrome Android 42 Firefox Android 45 Opera Android 29 Safari iOS 7 Samsung Internet Android 4.0 nodejs 6.0.0
6.0.0
5.0.0 Disabled
Disabled From version 5.0.0: this feature is behind the --harmony runtime flag.
逗号运算符 Chrome 1 Edge 12 Firefox 1 IE 3 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Conditional operator ( c ? t : f ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Decrement ( -- ) Chrome 2 Edge 12 Firefox 1 IE 3 Opera 3 Safari 4 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 3.2 Samsung Internet Android 1.0 nodejs 0.1.100
delete Chrome 1 Edge 12 Firefox 1 IE 4 Opera 9 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Destructuring assignment Chrome 49 Edge 14 Firefox 41
41
Firefox provided a non-standard destructuring implementation from Firefox 2 to 40.
IE No Opera 36 Safari 8 WebView Android 49 Chrome Android 49 Firefox Android 41
41
Firefox provided a non-standard destructuring implementation from Firefox 2 to 40.
Opera Android 36 Safari iOS 8 Samsung Internet Android 5.0 nodejs 6.0.0
Division ( / ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Division assignment ( x /= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Equality ( a == b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Exponentiation ( ** ) Chrome 52 Edge 14 Firefox 52 IE No Opera 39 Safari 10.1 WebView Android 51 Chrome Android 52 Firefox Android 52 Opera Android 41 Safari iOS 10.3 Samsung Internet Android 6.0 nodejs 7.0.0
7.0.0
6.5.0 Disabled
Disabled From version 6.5.0: this feature is behind the --harmony runtime flag.
Exponentiation assignment ( x **= y ) Chrome 52 Edge 14 Firefox 52 IE No Opera 39 Safari 10.1 WebView Android 51 Chrome Android 52 Firefox Android 52 Opera Android 41 Safari iOS 10.3 Samsung Internet Android 6.0 nodejs 7.0.0
7.0.0
6.5.0 Disabled
Disabled From version 6.5.0: this feature is behind the --harmony runtime flag.
function Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
function* Chrome 49 Edge 12 Firefox 26 IE No Opera 36 Safari 10 WebView Android 49 Chrome Android 49 Firefox Android 26 Opera Android 36 Safari iOS 10 Samsung Internet Android 5.0 nodejs 4.0.0
Greater than ( a > b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Greater than or equal ( a >= b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Grouping operator () Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
in Chrome 1 Edge 12 Firefox 1 IE 5.5 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Increment ( ++ ) Chrome 2 Edge 12 Firefox 1 IE 3 Opera 3 Safari 4 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 3.2 Samsung Internet Android 1.0 nodejs 0.1.100
Inequality ( a != b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
instanceof Chrome 1 Edge 12 Firefox 1 IE 5 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise left shift ( a << b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Left shift assignment ( x <<= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Less than ( a < b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Less than or equal ( a <= b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Logical AND ( && ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Logical AND assignment ( x &&= y ) Chrome 85 Edge 85 Firefox 79 IE No Opera No Safari 14 WebView Android 85 Chrome Android 85 Firefox Android No Opera Android No Safari iOS 14 Samsung Internet Android No nodejs No
Logical NOT ( ! ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Logical nullish assignment ( x ??= y ) Chrome 85 Edge 85 Firefox 79 IE No Opera No Safari 14 WebView Android 85 Chrome Android 85 Firefox Android No Opera Android No Safari iOS 14 Samsung Internet Android No nodejs No
Logical OR ( || ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Logical OR assignment ( x ||= y ) Chrome 85 Edge 85 Firefox 79 IE No Opera No Safari 14 WebView Android 85 Chrome Android 85 Firefox Android No Opera Android No Safari iOS 14 Samsung Internet Android No nodejs No
Multiplication ( * ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Multiplication assignment ( x *= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
new Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
new.target Chrome 46 Edge 13 Firefox 41 IE No Opera 33 Safari 11 WebView Android 46 Chrome Android 46 Firefox Android 41 Opera Android 33 Safari iOS 11 Samsung Internet Android 5.0 nodejs 5.0.0
Nullish coalescing operator ( ?? ) Chrome 80 Edge 80 Firefox 72 IE No Opera 67 Safari 13.1 WebView Android 80 Chrome Android 80 Firefox Android No Opera Android No Safari iOS 13.4 Samsung Internet Android No nodejs 14.0.0
对象初始化器 Chrome 1 Edge 12 Firefox 1 IE 1 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Optional chaining operator ( ?. ) Chrome 80
80
79 Disabled
Disabled ). To change preferences in Chrome, visit
Edge 80
80
79 Disabled
Disabled From version 79: this feature is behind the Experimental JavaScript preference (needs to be set to true ).
Firefox 74 IE No Opera 67
67
66 Disabled
Disabled From version 66: this feature is behind the Experimental JavaScript preference (needs to be set to true ).
Safari 13.1 WebView Android 80 Chrome Android 80
80
79 Disabled
Disabled ). To change preferences in Chrome, visit
Firefox Android No Opera Android No Safari iOS 13.4 Samsung Internet Android No nodejs 14.0.0
Pipeline operator ( |> ) Chrome No Edge No Firefox No IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android No Opera Android No Safari iOS No Samsung Internet Android No nodejs No
特性访问器 Chrome 1 Edge 12 Firefox 1 IE 3 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Remainder ( % ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Remainder assignment ( x %= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise right shift ( a >> b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Right shift assignment ( x >>= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Strict equality ( a === b ) Chrome 1 Edge 12 Firefox 1 IE 4 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Strict inequality ( a !== b ) Chrome 1 Edge 12 Firefox 1 IE 4 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Subtraction ( - ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Subtraction assignment ( x -= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
super Chrome 42 Edge 13 Firefox 45 IE No Opera 29 Safari 7 WebView Android 42 Chrome Android 42 Firefox Android 45 Opera Android 29 Safari iOS 7 Samsung Internet Android 4.0 nodejs 6.0.0
this Chrome 1 Edge 12 Firefox 1 IE 4 Opera 9.5 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
typeof Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Unary negation ( - ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Unary plus ( + ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 4 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Bitwise unsigned right shift ( a >>> b ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
Unsigned right shift assignment ( x >>>= y ) Chrome 1 Edge 12 Firefox 1 IE 3 Opera 3 Safari 1 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 1 Samsung Internet Android 1.0 nodejs 0.1.100
void Chrome 1 Edge 12 Firefox 1 IE 5 Opera 4 Safari 3.2 WebView Android 1 Chrome Android 18 Firefox Android 4 Opera Android 10.1 Safari iOS 3 Samsung Internet Android 1.0 nodejs 0.1.100
yield Chrome 39 Edge 12 Firefox 26
26
Starting with Firefox 33, the parsing of the yield expression has been updated to conform with the ES2015 specification.
Starting with Firefox 29, an IteratorResult object returned for completed generator function.
IE No Opera 26 Safari 10 WebView Android 39 Chrome Android 39 Firefox Android 26
26
Starting with Firefox 33, the parsing of the yield expression has been updated to conform with the ES2015 specification.
Starting with Firefox 29, an IteratorResult object returned for completed generator function.
Opera Android 26 Safari iOS 10 Samsung Internet Android 4.0 nodejs 4.0.0
4.0.0
0.12 Disabled
Disabled From version 0.12: this feature is behind the --harmony runtime flag.
yield* Chrome 39 Edge 12 Firefox 27
27
Starting with Firefox 33, the parsing of the yield expression has been updated to conform with the ES2015 specification.
IE No Opera 26 Safari 10 WebView Android 39 Chrome Android 39 Firefox Android 27
27
Starting with Firefox 33, the parsing of the yield expression has been updated to conform with the ES2015 specification.
Opera Android 26 Safari iOS 10 Samsung Internet Android 4.0 nodejs 4.0.0
4.0.0
0.12 Disabled
Disabled From version 0.12: this feature is behind the --harmony runtime flag.

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

另请参阅

元数据

  • 最后修改:
  1. JavaScript
  2. 教程:
  3. 完全初学者
    1. JavaScript 基础
    2. JavaScript 第一步
    3. JavaScript 构建块
    4. 引入 JavaScript 对象
  4. JavaScript 指南
    1. 介绍
    2. 语法和类型
    3. 控制流程和错误处理
    4. 循环和迭代
    5. 函数
    6. 表达式和运算符
    7. 数字和日期
    8. 文本格式化
    9. 正则表达式
    10. 索引集合
    11. 键控集合
    12. Working with objects
    13. 对象模型的细节
    14. Using promises
    15. 迭代器和生成器
    16. Meta programming
    17. JavaScript 模块
  5. 中间体
    1. Client-side JavaScript frameworks
    2. 客户端侧 Web API
    3. 重新介绍 JavaScript
    4. JavaScript 数据结构
    5. 相等比较和相同
    6. 闭包
  6. 高级
    1. 继承和原型链
    2. 严格模式
    3. JavaScript 类型数组
    4. 内存管理
    5. 并发模型和事件循环
  7. 参考:
  8. 内置对象
    1. AggregateError
    2. Array
    3. ArrayBuffer
    4. AsyncFunction
    5. Atomics
    6. BigInt
    7. BigInt64Array
    8. BigUint64Array
    9. 布尔
    10. DataView
    11. Date
    12. Error
    13. EvalError
    14. FinalizationRegistry
    15. Float32Array
    16. Float64Array
    17. Function
    18. Generator
    19. GeneratorFunction
    20. Infinity
    21. Int16Array
    22. Int32Array
    23. Int8Array
    24. InternalError
    25. Intl
    26. JSON
    27. Map
    28. Math
    29. NaN
    30. Number
    31. Object
    32. Promise
    33. Proxy
    34. RangeError
    35. ReferenceError
    36. Reflect
    37. RegExp
    38. Set
    39. SharedArrayBuffer
    40. String
    41. Symbol
    42. SyntaxError
    43. TypeError
    44. TypedArray
    45. URIError
    46. Uint16Array
    47. Uint32Array
    48. Uint8Array
    49. Uint8ClampedArray
    50. WeakMap
    51. WeakRef
    52. WeakSet
    53. WebAssembly
    54. decodeURI()
    55. decodeURIComponent()
    56. encodeURI()
    57. encodeURIComponent()
    58. escape()
    59. eval()
    60. globalThis
    61. isFinite()
    62. isNaN()
    63. null
    64. parseFloat()
    65. parseInt()
    66. undefined
    67. unescape()
    68. uneval()
  9. 表达式 & 运算符
    1. Addition (+)
    2. Addition assignment (+=)
    3. Assignment (=)
    4. Bitwise AND (&)
    5. Bitwise AND assignment (&=)
    6. Bitwise NOT (~)
    7. Bitwise OR (|)
    8. Bitwise OR assignment (|=)
    9. Bitwise XOR (^)
    10. Bitwise XOR assignment (^=)
    11. Comma operator (,)
    12. 条件 (三元) 运算符
    13. Decrement (--)
    14. Destructuring assignment
    15. Division (/)
    16. Division assignment (/=)
    17. Equality (==)
    18. Exponentiation (**)
    19. Exponentiation assignment (**=)
    20. 函数表达式
    21. Greater than (>)
    22. Greater than or equal (>=)
    23. Grouping operator ( )
    24. Increment (++)
    25. Inequality (!=)
    26. Left shift (<<)
    27. Left shift assignment (<<=)
    28. Less than (<)
    29. Less than or equal (<=)
    30. Logical AND (&&)
    31. Logical AND assignment (&&=)
    32. Logical NOT (!)
    33. Logical OR (||)
    34. Logical OR assignment (||=)
    35. Logical nullish assignment (??=)
    36. Multiplication (*)
    37. Multiplication assignment (*=)
    38. Nullish coalescing operator (??)
    39. 对象初始化器
    40. 运算符优先级
    41. Optional chaining (?.)
    42. Pipeline operator (|>)
    43. 特性访问器
    44. Remainder (%)
    45. Remainder assignment (%=)
    46. Right shift (>>)
    47. Right shift assignment (>>=)
    48. Spread syntax (...)
    49. Strict equality (===)
    50. Strict inequality (!==)
    51. Subtraction (-)
    52. Subtraction assignment (-=)
    53. Unary negation (-)
    54. Unary plus (+)
    55. Unsigned right shift (>>>)
    56. Unsigned right shift assignment (>>>=)
    57. 异步函数表达式
    58. await
    59. class expression
    60. delete operator
    61. function* 表达式
    62. in operator
    63. instanceof
    64. new operator
    65. new.target
    66. super
    67. this
    68. typeof
    69. void 运算符
    70. yield
    71. yield*
  10. 语句 & 声明
    1. async function
    2. block
    3. break
    4. class
    5. const
    6. continue
    7. debugger
    8. do...while
    9. empty
    10. export
    11. for
    12. for await...of
    13. for...in
    14. for...of
    15. 函数声明
    16. function*
    17. if...else
    18. import
    19. import.meta
    20. label
    21. let
    22. return
    23. switch
    24. throw
    25. try...catch
    26. var
    27. while
    28. with
  11. 函数
    1. 箭头函数表达式
    2. 默认参数
    3. 方法定义
    4. 其余参数
    5. 自变量对象
    6. getter
    7. setter
    1. Private class fields
    2. Public class fields
    3. 构造函数
    4. extends
    5. static
  12. 错误
    1. Error: Permission denied to access property "x"
    2. InternalError: too much recursion
    3. RangeError: argument is not a valid code point
    4. RangeError: invalid array length
    5. RangeError: invalid date
    6. RangeError: precision is out of range
    7. RangeError: radix must be an integer
    8. RangeError: repeat count must be less than infinity
    9. RangeError: repeat count must be non-negative
    10. ReferenceError: "x" is not defined
    11. ReferenceError: assignment to undeclared variable "x"
    12. ReferenceError: can't access lexical declaration`X' before initialization
    13. ReferenceError: deprecated caller or arguments usage
    14. ReferenceError: invalid assignment left-hand side
    15. ReferenceError: reference to undefined property "x"
    16. SyntaxError: "0"-prefixed octal literals and octal escape seq. are deprecated
    17. SyntaxError: "use strict" not allowed in function with non-simple parameters
    18. SyntaxError: "x" is a reserved identifier
    19. SyntaxError: JSON.parse: bad parsing
    20. SyntaxError: Malformed formal parameter
    21. SyntaxError: Unexpected token
    22. SyntaxError: Using //@ to indicate sourceURL pragmas is deprecated. Use //# instead
    23. SyntaxError: a declaration in the head of a for-of loop can't have an initializer
    24. SyntaxError: applying the 'delete' operator to an unqualified name is deprecated
    25. SyntaxError: for-in loop head declarations may not have initializers
    26. SyntaxError: function statement requires a name
    27. SyntaxError: identifier starts immediately after numeric literal
    28. SyntaxError: illegal character
    29. SyntaxError: invalid regular expression flag "x"
    30. SyntaxError: missing ) after argument list
    31. SyntaxError: missing ) after condition
    32. SyntaxError: missing : after property id
    33. SyntaxError: missing ; before statement
    34. SyntaxError: missing = in const declaration
    35. SyntaxError: missing ] after element list
    36. SyntaxError: missing formal parameter
    37. SyntaxError: missing name after . operator
    38. SyntaxError: missing variable name
    39. SyntaxError: missing } after function body
    40. SyntaxError: missing } after property list
    41. SyntaxError: redeclaration of formal parameter "x"
    42. SyntaxError: return not in function
    43. SyntaxError: test for equality (==) mistyped as assignment (=)?
    44. SyntaxError: unterminated string literal
    45. TypeError: "x" has no properties
    46. TypeError: "x" is (not) "y"
    47. TypeError: "x" is not a constructor
    48. TypeError: "x" is not a function
    49. TypeError: "x" is not a non-null object
    50. TypeError: "x" is read-only
    51. TypeError: 'x' is not iterable
    52. TypeError: More arguments needed
    53. TypeError: Reduce of empty array with no initial value
    54. TypeError: X.prototype.y called on incompatible type
    55. TypeError: can't access dead object
    56. TypeError: can't access property "x" of "y"
    57. TypeError: can't assign to property "x" on "y": not an object
    58. TypeError: can't define property "x": "obj" is not extensible
    59. TypeError: can't delete non-configurable array element
    60. TypeError: can't redefine non-configurable property "x"
    61. TypeError: cannot use 'in' operator to search for 'x' in 'y'
    62. TypeError: cyclic object value
    63. TypeError: invalid 'instanceof' operand 'x'
    64. TypeError: invalid Array.prototype.sort argument
    65. TypeError: invalid arguments
    66. TypeError: invalid assignment to const "x"
    67. TypeError: property "x" is non-configurable and can't be deleted
    68. TypeError: setting getter-only property "x"
    69. TypeError: variable "x" redeclares argument
    70. URIError: malformed URI sequence
    71. Warning: -file- is being assigned a //# sourceMappingURL, but already has one
    72. Warning: 08/09 is not a legal ECMA-262 octal constant
    73. Warning: Date.prototype.toLocaleFormat is deprecated
    74. Warning: JavaScript 1.6's for-each-in loops are deprecated
    75. Warning: String.x is deprecated; use String.prototype.x instead
    76. Warning: expression closures are deprecated
    77. Warning: unreachable code after return statement
  13. 杂项
    1. JavaScript 技术概述
    2. 词法语法
    3. JavaScript 数据结构
    4. Enumerability and ownership of properties
    5. Iteration protocols
    6. 严格模式
    7. 过渡到严格模式
    8. 模板文字
    9. 弃用特征

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1