Empty Statements

By: Dusty Arlia
Published on Saturday, April 13, 2013, 04:48 PM
Last Updated on Wednesday, July 08, 2015 at 8:40 PM
Total Updates: 5

An empty JavaScript statement is just a semicolon like this:


Empty statements don't do anything, but are sometimes necessary when some sort of JavaScript statement is expected. For example, they are used in loops that don't need anything in the body of the loop. For example:

for(i = 0; i < employees.length; employees[i++] = 0) {
; //empty statement on purpose

It's a good habit to leave a comment noting that you are intentionally leaving an empty statement.