Use of semicolon in JavaScript

Why it is not necessary to use semicolon after every JavaScript code? Do you recommend using semicolons after every statement in JavaScript?

Last updated:7/19/2021 5:11:04 AM

1 Answers

Ethan Karla
Ethan Karla

It is necessary to use a semicolon to end each statement of JavaScript code and to continue writing the second statement, but if that would be the last statement then JavaScript would work normally without the semicolon. But, remember that it is good habit for developers to code with rules.
So Yes, you should use semicolons after every statement in JavaScript.