The semicolon is optional when statements are followed by a line break.
The semicolon is required when you have two or more statements on the same line.
The semicolon is optional when you have a block containing a single statement.

Not After Round Brackets

In these examples JavaScript interprets the semicolon as an empty statement.
Any lines underneath will not belong to the condition statement.

if ( 0 === 1) 
for ( )
switch ( )

Inside For Loop

You do need to include semicolons after the first and second statements inside a for loop.

for ( var i = 0; i < 5; i++) 

© 2019 Better Solutions Limited. All Rights Reserved. © 2019 Better Solutions Limited TopPrevNext