JavaScript 应用程序是由许多语法正确的语句组成的。单个语句可以跨多行。如果每个语句用分号隔开，那么多个语句可以在一行中出现。本页的内容并不是一个关键字，而是一组关键字。

## 语句和声明（按类别分类）

对于字母顺序列表，请参阅左边的侧边栏。

### 控制流程

`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.）

### 声明

`var`
  声明一个变量，可同时将其初始化为一个值。
`let`
  声明一个块级本地变量，可同时将其初始化为一个值。
`const`
  声明一个只读的命名常量。

### 函数和类

`function`
  声明一个指定参数的函数。
`function*`
  生成器函数使迭代器更容易使用。
`return`
  指定函数的返回值。
`class`
  声明一个类。

### 迭代器

`do...while`
  创建一个循环来执行语句，直到该语句条件表达式的值为false。先执行语句，再执行条件表达式，该语句至少会执行一次。
`for`
  创建一个由3个可选的表达式组成的循环，该循环用括号包裹，分号分割，并在循环体中执行语句。
`for each...in`
  通过指定的变量迭代对象所有属性的值。针对每个唯一的属性，会执行指定的语句块。
`for...in`
  无序遍历对象的可枚举属性。语句针对每个唯一的属性。
`for...of`
  遍历可迭代的对象 (包括 `数组`, 类数组对象, iterators and generators)，对每个不同属性的属性，调用一个自定义的有执行语句的迭代钩子。
`for await...of`
  Iterates over async iterable objects, array-like objects, iterators and generators, invoking a custom iteration hook with statements to be executed for the value of each distinct property.
`while`
  创建一个循环语句，循环会一直持续到该语句条件表达式的值为false。先执行条件表达式，然后执行语句。

### 其他

`debugger`
  调用可用的调试功能。如果没有调试功能可用，该语句不生效。
`export`
  用来导出函数，以便这些函数能够被导入到外部模块或其他脚本中。
`import`
  用来引入外部的模块或另一个script中导出的函数。
`import.meta`
  A meta-property exposing context-specific metadata to a JavaScript module.
`label`
  带标识的语句，与`break`或`continue语句一起使用。`

`with`
  拓展一个语句的作用域。

## 规范

规范 | 状态 | 备注
--- | --- | ---
ECMAScript 1st Edition (ECMA-262) Statements | Standard | Initial definition
ECMAScript 3rd Edition (ECMA-262) Statements | Standard |
ECMAScript 5.1 (ECMA-262) Statements | Standard |
ECMAScript 2015 (6th Edition, ECMA-262) ECMAScript Language: Statements and Declarations | Standard | New: function*, let, for...of, yield, class
ECMAScript Latest Draft (ECMA-262) ECMAScript Language: Statements and Declarations | Draft |

## Browser compatibility

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.

Update compatibility data on GitHub

| Desktop | Mobile | Server
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | Safari on iOS | Samsung Internet | Node.js
Legacy generator function Deprecated Non-standard | Chrome No support No | Edge No support No | Firefox No support 2 — 58 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile No support No | Firefox Android No support 4 — 58 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No
`async function` | Chrome Full support 55 | Edge Full support Yes | Firefox Full support 52 | IE No support No | Opera Full support 42 | Safari Full support 10.1 | WebView Android Full support Yes | Chrome Android Full support 55 | Edge Mobile Full support Yes | Firefox Android Full support 52 | Opera Android Full support 42 | Safari iOS Full support 10.1 | Samsung Internet Android Full support 6.0 | nodejs Full support 7.6.0 Full support 7.6.0 Full support 7.0.0 Disabled Disabled From version 7.0.0: this feature is behind the `--harmony` runtime flag.
`block` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`break` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`class` | Chrome Full support 42 | Edge Full support Yes | Firefox Full support 45 | IE No support No | Opera Full support 36 | Safari Full support 10.1 | WebView Android Full support 42 | Chrome Android Full support 42 | Edge Mobile Full support Yes | Firefox Android Full support 45 | Opera Android ? | Safari iOS Full support 10.1 | Samsung Internet Android Full support 4.0 | nodejs Full support 6.0.0
`const` | Chrome Full support 21 | Edge Full support Yes | Firefox Full support 36 Notes Full support 36 Notes Notes Prior to Firefox 13, `const` is implemented, but re-assignment is not failing. Notes Prior to Firefox 46, a `TypeError` was thrown on redeclaration instead of a `SyntaxError`. | IE Full support 11 | Opera Full support Yes | Safari Full support 5.1 | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 36 Notes Full support 36 Notes Notes Prior to Firefox 13, `const` is implemented, but re-assignment is not failing. Notes Prior to Firefox 46, a `TypeError` was thrown on redeclaration instead of a `SyntaxError`. | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`continue` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`debugger` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`do...while` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support 6 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
Empty statement (`;`) | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`export` | Chrome Full support 61 | Edge Full support 16 Full support 16 Full support 15 Disabled Disabled From version 15: this feature is behind the `Experimental JavaScript Features` preference. | Firefox Full support 60 Full support 60 No support 54 — 60 Disabled Disabled From version 54 until version 60 (exclusive): this feature is behind the `dom.moduleScripts.enabled` preference. To change preferences in Firefox, visit about:config. | IE No support No | Opera Full support 47 | Safari Full support 10.1 | WebView Android No support No | Chrome Android Full support 61 | Edge Mobile Full support Yes | Firefox Android Full support 60 Full support 60 No support 54 — 60 Disabled Disabled From version 54 until version 60 (exclusive): this feature is behind the `dom.moduleScripts.enabled` preference. To change preferences in Firefox, visit about:config. | Opera Android Full support 47 | Safari iOS Full support 10.1 | Samsung Internet Android No support No | nodejs ?
`for` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`for await...of` Experimental | Chrome Full support 63 | Edge No support No | Firefox Full support 57 | IE No support No | Opera Full support 50 | Safari Full support 11 | WebView Android Full support 63 | Chrome Android Full support 63 | Edge Mobile No support No | Firefox Android ? | Opera Android Full support 50 | Safari iOS ? | Samsung Internet Android ? | nodejs ?
`for each...in` Deprecated Non-standard | Chrome No support No | Edge No support No | Firefox No support 1.5 — 57 | IE No support No | Opera No support No | Safari No support No | WebView Android No support No | Chrome Android No support No | Edge Mobile No support No | Firefox Android No support 4 — 57 | Opera Android No support No | Safari iOS No support No | Samsung Internet Android No support No | nodejs No support No
`for...in` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support 6 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`for...of` | Chrome Full support 38 | Edge Full support 12 | Firefox Full support 13 Notes Full support 13 Notes Notes Prior to Firefox 51, using the `for...of` loop construct with the `const` keyword threw a `SyntaxError` ("missing = in const declaration"). | IE No support No | Opera Full support 25 | Safari Full support 8 | WebView Android Full support 38 | Chrome Android Full support Yes | Edge Mobile Full support 12 | Firefox Android Full support 14 Notes Full support 14 Notes Notes Prior to Firefox 51, using the `for...of` loop construct with the `const` keyword threw a `SyntaxError` ("missing = in const declaration"). | Opera Android Full support 25 | Safari iOS Full support 8 | Samsung Internet Android Full support Yes | nodejs Full support Yes
`function` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`function*` | Chrome Full support 39 | Edge Full support 13 | Firefox Full support 26 | IE No support No | Opera Full support 26 | Safari Full support 10 | WebView Android Full support Yes | Chrome Android Full support 39 | Edge Mobile Full support Yes | Firefox Android Full support 26 | Opera Android Full support Yes | Safari iOS Full support 10 | Samsung Internet Android Full support 4.0 | nodejs Full support 4.0.0 Full support 4.0.0 Full support 0.12 Disabled Disabled From version 0.12: this feature is behind the `--harmony` runtime flag.
`if...else` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`import` | Chrome Full support 61 | Edge Full support 16 Full support 16 Full support 15 Disabled Disabled From version 15: this feature is behind the `Experimental JavaScript Features` preference. | Firefox Full support 60 Full support 60 No support 54 — 60 Disabled Disabled From version 54 until version 60 (exclusive): this feature is behind the `dom.moduleScripts.enabled` preference. To change preferences in Firefox, visit about:config. | IE No support No | Opera Full support 47 | Safari Full support 10.1 | WebView Android Full support 61 | Chrome Android Full support 61 | Edge Mobile Full support Yes | Firefox Android Full support 60 Full support 60 No support 54 — 60 Disabled Disabled From version 54 until version 60 (exclusive): this feature is behind the `dom.moduleScripts.enabled` preference. To change preferences in Firefox, visit about:config. | Opera Android Full support 47 | Safari iOS Full support 10.1 | Samsung Internet Android No support No | nodejs Full support 8.5.0 Notes Disabled Full support 8.5.0 Notes Disabled Notes files must have suffix .mjs, not .js Disabled From version 8.5.0: this feature is behind the `--experimental-modules` runtime flag.
`import.meta` | Chrome Full support 64 | Edge ? | Firefox Full support 62 | IE No support No | Opera Full support 51 | Safari Full support 11.1 | WebView Android Full support 64 | Chrome Android Full support 64 | Edge Mobile ? | Firefox Android Full support 62 | Opera Android Full support 51 | Safari iOS Full support 12 | Samsung Internet Android No support No | nodejs ?
`label` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`let` | Chrome Full support 49 Full support 49 No support 48 — 49 Notes Disabled Notes Support outside of strict mode. Disabled From version 48 until version 49 (exclusive): this feature is behind the `Enable Experimental JavaScript Features` preference. To change preferences in Chrome, visit chrome://flags. No support 41 — 49 Notes Notes Strict mode is required. | Edge Full support 12 | Firefox Full support 44 Notes Full support 44 Notes Notes Prior to Firefox 44, `let` is only available to code blocks in HTML wrapped in a `<script type="application/javascript;version=1.7">` block (or higher version) and has different semantics (e.g. no temporal dead zone). Notes Prior to Firefox 46, a `TypeError` is thrown on redeclaration instead of a `SyntaxError`. Notes Firefox 54 adds support of `let` in workers. | IE Full support 11 | Opera Full support 17 | Safari Full support 10 | WebView Android Full support 49 Full support 49 No support 41 — 49 Notes Notes Strict mode is required. | Chrome Android Full support 49 Full support 49 No support 48 — 49 Notes Disabled Notes Support outside of strict mode. Disabled From version 48 until version 49 (exclusive): this feature is behind the `Enable Experimental JavaScript Features` preference. To change preferences in Chrome, visit chrome://flags. No support 41 — 49 Notes Notes Strict mode is required. | Edge Mobile Full support 12 | Firefox Android Full support 44 Notes Full support 44 Notes Notes Prior to Firefox 44, `let` is only available to code blocks in HTML wrapped in a `<script type="application/javascript;version=1.7">` block (or higher version) and has different semantics (e.g. no temporal dead zone). Notes Prior to Firefox 46, a `TypeError` is thrown on redeclaration instead of a `SyntaxError`. Notes Firefox 54 adds support of `let` in workers. | Opera Android Full support 17 | Safari iOS Full support 10 | Samsung Internet Android Full support 4.0 | nodejs Full support 6.0.0
`return` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`switch` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`throw` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`try...catch` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support 6 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`var` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`while` | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes
`with` Deprecated | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes

### Legend

Full support
  Full support
No support
  No support
Compatibility unknown
  Compatibility unknown
Experimental. Expect behavior to change in the future.
  Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
  Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
  Deprecated. Not for use in new websites.
See implementation notes.
  See implementation notes.
User must explicitly enable this feature.
  User must explicitly enable this feature.

## 参见

- 运算符