Is Semicolon Mandatory in Javascript?

Is Semicolon Mandatory in Javascript?

No, semicolons are usually optional in JavaScript (Google for ASI / automatic semicolon insertion). Using them makes the code look much cleaner though and ASI is a horrible mis-feature (at least in my opinion).

Are semicolons required in JavaScript?

Semicolons are not required for JavaScript programming, nevertheless I advice you to use it. It makes your code more readable and is actually a good practice, and almost all cool programming languages uses it. Take a stand and use it, it's up to you now!

What is the purpose of a semicolon in JavaScript?

Semicolons are an essential part of JavaScript code. They are read and used by the compiler to distinguish between separate statements so that statements do not leak into other parts of the code.

Maya Lin-Takahashi
Author

Maya Lin-Takahashi

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.