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.
Statements and declarations by category
For an alphabetical listing see the sidebar on the left.
Control flow
- 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
- Throws a user-defined exception.
try...catch
- Marks a block of statements to try, and specifies a response, should an exception be thrown.
Declarations
var
- Declares a variable, optionally initializing it to a value.
let
- Declares a block scope local variable, optionally initializing it to a value.
const
- Declares a read-only named constant.
Functions and classes
function
- Declares a function with the specified parameters.
function*
- Generator Functions enable writing iterators more easily.
async function
- Declares an async function with the specified parameters.
return
- Specifies the value to be returned by a function.
class
- Declares a class.
Iterations
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.
- [[../../../../Archive/Web/JavaScript/for_each..|
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
- Iterates over iterable objects (including arrays, array-like objects, iterators and generators), invoking a custom iteration hook with statements to be executed for the value of each distinct property.
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
- 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.
Others
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.
- label
- Provides a statement with an identifier that you can refer to using a
break
orcontinue
statement.
with
- Extends the scope chain for a statement.
Specifications
Specification |
---|
ECMAScript (ECMA-262)The definition of 'ECMAScript Language: Statements and Declarations' in that specification. |
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
async function
|
Chrome
Full support 55 |
Edge
Full support 15 |
Firefox
Full support 52 |
IE
No support No |
Opera
Full support 42 |
Safari
Full support 10.1 |
WebView Android
Full support 55 |
Chrome Android
Full support 55 |
Firefox Android
Full support 52 |
Opera Android
Full support 42 |
Safari iOS
Full support 10.3 |
Samsung Internet Android
Full support 6.0 |
nodejs Full support 7.6.0 Full support 7.6.0 Full support 7.0.0 Disabled' From version 7.0.0: this feature is behind the |
block
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 11 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
break
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
class
|
Chrome Full support 49 Full support 49 No support 42 — 49 Notes' Strict mode is required. No support 42 — 49 Disabled' From version 42 until version 49 (exclusive): this feature is behind the |
Edge
Full support 13 |
Firefox
Full support 45 |
IE
No support No |
Opera Full support 36 Full support 36 No support 29 — 36 Notes' Strict mode is required. No support 29 — 36 Disabled' From version 29 until version 36 (exclusive): this feature is behind the |
Safari
Full support 10.1 |
WebView Android Full support 49 Full support 49 No support 42 — 49 Notes' Strict mode is required. |
Chrome Android Full support 49 Full support 49 No support 42 — 49 Notes' Strict mode is required. No support 42 — 49 Disabled' From version 42 until version 49 (exclusive): this feature is behind the |
Firefox Android
Full support 45 |
Opera Android Full support 36 Full support 36 No support 29 — 36 Notes' Strict mode is required. No support 29 — 36 Disabled' From version 29 until version 36 (exclusive): this feature is behind the |
Safari iOS
Full support 10.3 |
Samsung Internet Android Full support 5.0 Full support 5.0 No support 4.0 — 5.0 Notes' Strict mode is required. |
nodejs
Full support 6.0.0 |
const
|
Chrome
Full support 21 |
Edge
Full support 12 |
Firefox Full support 36 Full support 36 Notes' Prior to Firefox 13, |
IE
Full support 11 |
Opera
Full support 9 |
Safari
Full support 5.1 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 25 |
Firefox Android Full support 36 Full support 36 Notes' Prior to Firefox 13, |
Opera Android
Full support 10.1 |
Safari iOS
Full support 6 |
Samsung Internet Android
Full support 1.5 |
nodejs
Full support 6.0.0 |
continue
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
debugger
|
Chrome
Full support 5 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 10 |
Safari
Full support 5 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 4.2 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
do...while
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
Empty statement (; )
|
Chrome
Full support 3 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 5 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 4.2 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
export
|
Chrome
Full support 61 |
Edge Full support 16 Full support 16 Full support 15 Disabled' From version 15: this feature is behind the |
Firefox Full support 60 Full support 60 No support 54 — 60 Disabled' From version 54 until version 60 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 48 |
Safari
Full support 10.1 |
WebView Android
No support No |
Chrome Android
Full support 61 |
Firefox Android Full support 60 Full support 60 No support 54 — 60 Disabled' From version 54 until version 60 (exclusive): this feature is behind the |
Opera Android
Full support 45 |
Safari iOS
Full support 10.3 |
Samsung Internet Android
Full support 8.0 |
nodejs Full support 13.2.0 Full support 13.2.0 Notes' Modules must either have a filename ending in Notes' Modules must either have a filename ending in Notes' Module filenames must end with |
for
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
for await...of
|
Chrome
Full support 63 |
Edge
Full support 79 |
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 |
Firefox Android
Full support 57 |
Opera Android
Full support 46 |
Safari iOS
Full support 11 |
Samsung Internet Android
Full support 8.0 |
nodejs Full support 10.0.0 Full support 10.0.0 No support 8.10.0 — 10.0.0 Disabled' From version 8.10.0 until version 10.0.0 (exclusive): this feature is behind the |
for...in
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 6 |
Opera
Full support 2 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
for...of
|
Chrome
Full support 38 |
Edge
Full support 12 |
Firefox Full support 13 Full support 13 Notes' Prior to Firefox 51, using the |
IE
No support No |
Opera
Full support 25 |
Safari
Full support 7 |
WebView Android
Full support 38 |
Chrome Android
Full support 38 |
Firefox Android Full support 14 Full support 14 Notes' Prior to Firefox 51, using the |
Opera Android
Full support 25 |
Safari iOS
Full support 7 |
Samsung Internet Android
Full support 3.0 |
nodejs
Full support 0.12 |
function
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
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 39 |
Chrome Android
Full support 39 |
Firefox Android
Full support 26 |
Opera Android
Full support 26 |
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' From version 0.12: this feature is behind the |
if...else
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
import
|
Chrome
Full support 61 |
Edge Full support 16 Full support 16 Full support 15 Disabled' From version 15: this feature is behind the |
Firefox Full support 60 Full support 60 No support 54 — 60 Disabled' From version 54 until version 60 (exclusive): this feature is behind the |
IE
No support No |
Opera
Full support 48 |
Safari
Full support 10.1 |
WebView Android
Full support 61 |
Chrome Android
Full support 61 |
Firefox Android Full support 60 Full support 60 No support 54 — 60 Disabled' From version 54 until version 60 (exclusive): this feature is behind the |
Opera Android
Full support 45 |
Safari iOS
Full support 10.3 |
Samsung Internet Android
Full support 8.0 |
nodejs Full support 13.2.0 Full support 13.2.0 Notes' Modules must either have a filename ending in Notes' Modules must either have a filename ending in Notes' Module filenames must end with |
import.meta
|
Chrome
Full support 64 |
Edge
Full support 79 |
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 |
Firefox Android
Full support 62 |
Opera Android
Full support 47 |
Safari iOS
Full support 12 |
Samsung Internet Android
Full support 9.0 |
nodejs
Full support 10.4.0 |
label
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
let
|
Chrome Full support 49 Full support 49 No support 48 — 49 Notes' Support outside of strict mode.
Disabled' From version 48 until version 49 (exclusive): this feature is behind the Notes' Strict mode is required. |
Edge Full support 14 Full support 14 No support 12 — 14 Notes' In Edge 12 and 13, |
Firefox Full support 44 Full support 44 Notes' Prior to Firefox 44, |
IE Partial support 11 Partial support 11 Notes' In Internet Explorer, |
Opera
Full support 17 |
Safari
Full support 10 |
WebView Android Full support 49 |
Chrome Android Full support 49 Full support 49 No support 48 — 49 Notes' Support outside of strict mode.
Disabled' From version 48 until version 49 (exclusive): this feature is behind the Notes' Strict mode is required. |
Firefox Android Full support 44 Full support 44 Notes' Prior to Firefox 44, |
Opera Android
Full support 18 |
Safari iOS
Full support 10 |
Samsung Internet Android Full support 5.0 |
nodejs
Full support 6.0.0 |
return
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
switch
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 4 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
throw
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 5 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
try...catch
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 5 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
var
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
while
|
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 3 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
Chrome
Full support 1 |
Edge
Full support 12 |
Firefox
Full support 1 |
IE
Full support 3 |
Opera
Full support 4 |
Safari
Full support 1 |
WebView Android
Full support 1 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 1 |
Samsung Internet Android
Full support 1.0 |
nodejs
Full support 0.1.100 |
Legend
- Full support
- Full support
- Partial support
- Partial support
- No support
- No 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.
See also
Statements and declarations by Mozilla Contributors is licensed under CC-BY-SA 2.5.