
- 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
When should I use a semicolon after curly braces 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.
In JavaScript, use a semi-colon after a statement. Let’s see an example of a variable assignment:
var s = function() { alert("Hello World!"); };
However, semicolons aren’t necessary for the following function declarations:
function() { alert("Hello World!"); };
- Related Articles
- Why should we use a semicolon after every function in JavaScript?
- Do I need to use a semicolon after every function in JavaScript?
- How to use Regex to get the string between curly braces using JavaScript?
- Golang program to create a block using curly braces
- When is a semicolon after } mandated in C++ Program?
- When should I use an Inline script and when to use external JavaScript file?
- When Should I use Selenium Grid?
- When should I use a composite index in MySQL?
- When should you use sets in Javascript?
- When should I use MySQL compressed protocol?
- Why is it considered a bad practice to omit curly braces in C/C++?
- Print 2D matrix in different lines and without curly braces in C/C++
- When should I use the keyword ‘this’ in a Java class?
- When you should not use JavaScript Arrow Functions?
- What is a smart pointer and when should I use it in C++?

Advertisements