Favorites

JavaScript Empty statement Statement

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Empty statement
JavaScript OtherThis statement is supported by all modern browsers.
Updated 28th November 2026

The empty statement is a lone semicolon where a statement is expected, meaning do nothing. It is occasionally used for loops with an empty body.

Description

An empty statement, a semicolon on its own, provides no statement where JavaScript expects one. It's sometimes used for a loop whose work is done entirely in its header. More often it appears by accident, as in if (x);, where the following block then always runs, so it's worth knowing to look for.

Empty statements are harmless on their own: an extra semicolon at the end of a line or after a function declaration doesn't change anything. The problems come from semicolons placed directly after if, for or while headers, where they end the statement and leave the following block to run unconditionally or only once.

Code formatters such as Prettier and linters such as ESLint (with rules like no-empty and no-extra-semi) catch these mistakes automatically. If you deliberately want a loop with an empty body, writing an empty block, {}, with a comment makes the intent clearer than a lone semicolon.

Syntax

;

Example

const arr = [1, 2, 3];
let i;
for (i = 0; i < arr.length && arr[i] !== 2; i++);
console.log('Index of 2:', i);

if (false); { console.log('This always runs: the ; ended the if'); }

Browser Support

The following information will show you the current browser support for the Empty statement statement. Hover over a browser icon to see the version that first introduced support for this statement.

This statement is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee