Expression statement - JavaScript | MDN

developer.mozilla.org

Tin mới

HTML: Markup language

See all HTML references

Date & time formats

See all HTML guides

CSS: Styling language

See all CSS references

See all CSS guides

Centering an element

JavaScript: Scripting language

Standard built-in objects

Expressions & operators

Statements & declarations

See all JavaScript references

Control flow & error handing

Loops and iteration

Working with objects

See all JavaScript guides

Web APIs: Programming interfaces

Service worker API

Using the Web animation API

Using the Fetch API

Working with the History API

Using the Web speech API

All web technology

Progressive web apps

Learn web development

Getting started modules

Structuring content with HTML module

CSS styling basics module

Dynamic scripting with JavaScript module

Border-image generator

Border-radius generator

Box-shadow generator

Color format converter

automatic semicolon insertion

Apart from the dedicated statement syntaxes, you can also use almost any expression as a statement on its own. The expression statement syntax requires a semicolon at the end, but the automatic semicolon insertion proces

Tagged template literals

function declaration

function* declaration

function expression

function* expression

async function declaration

async function* declaration

async function expression

async function* expression

array destructuring

Avoiding control flow statements

You can avoid almost all use of control flow statements using expression statements. For example, if...else can be replaced with ternary operators and logical operators. Iterative statements like for or for...of can be r

Avoiding control flow statements

You can avoid almost all use of control flow statements using expression statements. For example, if...else can be replaced with ternary operators and logical operators. Iterative statements like for or for...of can be r

Learn how to contribute

This page was last modified on Jul 8, 2025 by MDN contributors.

Expressions and operators

Numbers and strings