JavaScript Empty statement Statement
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
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.
Desktop





Tablets & Mobile





