
- 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
Why should we use a semicolon after every function in JavaScript?
Adding semicolons after every function is optional. To avoid undesirable results, while using functions expressions, use a semicolon.
Using semicolon
var display = function () { alert(“Hello World”); }; (function () { // code })();
Without using semicolon
var display = function () { alert(“Hello World”); } (function () { // code })();
The first function executes immediately since we have used the semicolon.
- Related Articles
- Do I need to use a semicolon after every function in JavaScript?
- When should I use a semicolon after curly braces in JavaScript?
- Why should we use element in JavaScript?
- Why should we not use ++, -- operators in JavaScript?
- Why we should use set.seed in R?
- Can we use semicolon as a MySQL DEMILITER?
- Why should we use MySQL CASE Statement?
- Why do we use a plus sign in front of function name in JavaScript?
- Why do we use "use strict" in JavaScript?
- Why we should use whole string in Java regular expression
- Why should we use a StringBuffer instead of a String in Java?\n
- What is SciPy and why should we use it?
- Why should we not use an umbrella during lightning?
- Why we should not use tables for HTML Layout?
- Why do we Use JavaScript in HTML?

Advertisements