JavaScript applications consist of statements with an appropriate syntax. A single statement may span multiple lines. Multiple statements may occur on a single line if each statement is separated by a semicolon. This isn't a keyword, but a group of keywords.
对于按字母顺序清单,请参阅左侧边栏。
Block
A block statement is used to group zero or more statements. The block is delimited by a pair of curly brackets.
break
Terminates the current loop, switch, or label statement and transfers program control to the statement following the terminated statement.
continue
Terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration.
Empty
An empty statement is used to provide no statement, although the JavaScript syntax would expect one.
if...else
Executes a statement if a specified condition is true. If the condition is false, another statement can be executed.
switch
Evaluates an expression, matching the expression's value to a case clause, and executes statements associated with that case.
throw
抛出用户定义的异常。
try...catch
Marks a block of statements to try, and specifies a response, should an exception be thrown.
function
采用指定参数声明函数。
function*
async function
采用指定参数声明异步函数。
return
指定由函数返回的值。
class
声明类。
do...while
Creates a loop that executes a specified statement until the test condition evaluates to false. The condition is evaluated after executing the statement, resulting in the specified statement executing at least once.
for
Creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement executed in the loop.
for each...in
Iterates a specified variable over all values of object's properties. For each distinct property, a specified statement is executed.
for...in
Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
for...of
for await...of
while
Creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement.
debugger
Invokes any available debugging functionality. If no debugging functionality is available, this statement has no effect.
export
Used to export functions to make them available for imports in external modules, and other scripts.
import
Used to import functions exported from an external module, another script.
import.meta
An object exposing context-specific metadata to a JavaScript module.
label
break
or
continue
语句。
with
扩展语句的作用域链。
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'ECMAScript Language: Statements and Declarations' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
async function
|
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
|
block
|
Chrome 1 | Edge 12 | Firefox 1 | IE 11 | 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 |
break
|
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 |
class
|
Chrome
49
|
Edge 13 | Firefox 45 | IE No |
Opera
36
|
Safari 10.1 |
WebView Android
49
|
Chrome Android
49
|
Firefox Android 45 |
Opera Android
36
|
Safari iOS 10.3 |
Samsung Internet Android
5.0
|
nodejs 6.0.0 |
const
|
Chrome 21 | Edge 12 |
Firefox
36
|
IE 11 | Opera 9 | Safari 5.1 | WebView Android ≤37 | Chrome Android 25 |
Firefox Android
36
|
Opera Android 10.1 | Safari iOS 6 | Samsung Internet Android 1.5 | nodejs 6.0.0 |
continue
|
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 |
debugger
|
Chrome 5 | Edge 12 | Firefox 1 | IE 4 | Opera 10 | Safari 5 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 4.2 | Samsung Internet Android 1.0 | nodejs 0.1.100 |
do...while
|
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 |
Empty statement (
;
)
|
Chrome 3 | Edge 12 | Firefox 1 | IE 3 | Opera 3 | Safari 5 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 4.2 | Samsung Internet Android 1.0 | nodejs 0.1.100 |
export
|
Chrome 61 |
Edge
16
|
Firefox
60
|
IE No | Opera 48 | Safari 10.1 | WebView Android No | Chrome Android 61 |
Firefox Android
60
|
Opera Android 45 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
nodejs
13.2.0
|
for
|
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 |
for await...of
|
Chrome 63 | Edge 79 | Firefox 57 | IE No | Opera 50 | Safari 11 | WebView Android 63 | Chrome Android 63 | Firefox Android 57 | Opera Android 46 | Safari iOS 11 | Samsung Internet Android 8.0 |
nodejs
10.0.0
|
for...in
|
Chrome 1 | Edge 12 | Firefox 1 | IE 6 | Opera 2 | 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 |
for...of
|
Chrome 38 | Edge 12 |
Firefox
13
|
IE No | Opera 25 | Safari 7 | WebView Android 38 | Chrome Android 38 |
Firefox Android
14
|
Opera Android 25 | Safari iOS 7 | Samsung Internet Android 3.0 | nodejs 0.12 |
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 39 | Edge 13 | Firefox 26 | IE No | Opera 26 | Safari 10 | WebView Android 39 | Chrome Android 39 | Firefox Android 26 | Opera Android 26 | Safari iOS 10 | Samsung Internet Android 4.0 |
nodejs
4.0.0
|
if...else
|
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 |
import
|
Chrome 61 |
Edge
16
|
Firefox
60
|
IE No | Opera 48 | Safari 10.1 | WebView Android 61 | Chrome Android 61 |
Firefox Android
60
|
Opera Android 45 | Safari iOS 10.3 | Samsung Internet Android 8.0 |
nodejs
13.2.0
|
import.meta
|
Chrome 64 | Edge 79 | Firefox 62 | IE No | Opera 51 | Safari 11.1 | WebView Android 64 | Chrome Android 64 | Firefox Android 62 | Opera Android 47 | Safari iOS 12 | Samsung Internet Android 9.0 | nodejs 10.4.0 |
label
|
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 |
let
|
Chrome 49 |
Edge
14
|
Firefox
44
|
IE
部分支持
11
|
Opera 17 | Safari 10 |
WebView Android
49
|
Chrome Android 49 |
Firefox Android
44
|
Opera Android 18 | Safari iOS 10 |
Samsung Internet Android
5.0
|
nodejs 6.0.0 |
return
|
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 |
switch
|
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 |
throw
|
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 |
try...catch
|
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 |
var
|
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 |
while
|
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 |
with
弃用
|
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 |
完整支持
部分支持
不支持
弃用。不要用于新网站。
见实现注意事项。
用户必须明确启用此特征。