
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
Do we need to use semicolons in JavaScript?
In JavaScript, Semicolons are optional. Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. JavaScript, however, allows you to omit this semicolon if each of your statements is placed on a separate line. It is a good programming practice to use semicolons.
For example, the following code could be written without semicolon.
<script> <!-- a = 5 b = 10 //--> </script>
But when formatted in a single line as follows, you must use semicolons −
<script> <!-- a = 5; b = 10; //--> </script>
- Related Articles
- Why do we need weakMaps in Javascript?
- Why do we use "use strict" in JavaScript?
- Do I need to use a semicolon after every function in JavaScript?
- Why do we Use JavaScript in HTML?
- Why do we need KDD?
- Why do we need Energy?
- Why do we need to study Physics?
- Why do we need to store food?
- What do we need to do to join Indian Army?
- How do we use throw statement in JavaScript?
- Why do we need generics in Java?
- Do we need forward declarations in Java?
- Why do we use jQuery over JavaScript?
- Why do we need a copy constructor and when should we use a copy constructor in Java?
- Why do we need Good Manners?

Advertisements