

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between semicolons in JavaScript and in Python?
Semicolons are optional in Python. In JavaScript, it s also optional, but it is a good practice to add it and is sometimes a necessity in case of some statements. If in these statements, a semicolon is not inserted, then one gets automatically added, but it may change the purpose of the code. This is called Automatic Semicolon Insertion.
Let’s see how −
The following is your code, with no semicolons:
function sub (p, q) { return p + q }
The above will actually be considered as the following −
function sub (p, q) { return; p + q; }
- Related Questions & Answers
- What is the difference between == and === in JavaScript?
- What is the difference between comments /*...*/ and /**...*/ in JavaScript?
- What is the difference between jQuery and JavaScript?
- What is the difference between JavaScript and C++?
- What is the difference between Java and JavaScript?
- What is the difference between JavaScript and ECMAScript?
- What is the difference between = and == operators in Python?
- What is the difference between window.onload and document.onload in Javascript?
- What is the difference between Bower and npm in JavaScript?
- What is the difference between call and apply in JavaScript?
- What is the difference between null and undefined in JavaScript?
- What is the difference between a++ and ++a in JavaScript?
- What is the difference between getter and setter in JavaScript?
- What is the difference between substr() and substring() in JavaScript?
- What is the difference between setTimeout() and setInterval() in JavaScript?
Advertisements