Students Empire

Learn Something New
Home

Statements


Javascript statements are terminated by a semicolon. Or you can omit the semicolon and let the parser determine where the end of a statement is.

Including semicolons helps prevent errors.

The first line of code has no semicolon. It leaves the parser to decide.

				var sum = a + b        //valid even without a semicolon - not recommended
				var diff = a - b;      //valid - preferred
				
				<!DOCTYPE HTML>
				<html>
				<body>
				<script type="text/javascript">
				    document.writeln("This is a statement");
				    document.writeln("This is also a statement");
				  </script>
				</body>
				</html>