![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements