How about Semicolons?

There’s been a lot of debate over semicolons in JavaScript. Semicolons aren’t required due to the nature of JavaScript’s automatic semicolon insertion, but they’ve been been considered a best practice for years.

I’d say definitely ALWAYS use them. Just because you can does not make it right. And I usually find it’s the lazy developers who do this!

One major advantage for always using them is if you want to minify your JavaScript. If you do not use semi colons, and you minify (like a lot of developers like to do if their site serves a lot of JavaScript), you could get all sorts of problems.

var myVar = 9
if (myVar == 9) {}

When minified, may become:

var myVar 9
if (myVar == 9) {}

And guess what? The script works unminified, but breaks due to a syntax error when minified, but if you drop in the semi colon where it should be, like this:

var myVar 9;
if (myVar == 9) {}

It works :">

Moral of the story, don’t be lazy & use them ❤