DEV Community

Discussion on: IIFEs in JavaScript and how to avoid this common mistake

Collapse
michi profile image
Michael Z Author

I really don't mind the use of semicolons, but personally haven't used them for some time now. It removes some clutter from the code and especially makes chains ([].map.filter etc.) easier to extend.

I am not fully convinced to use semicolons everywhere just for the edge case when a line starts with paranthesis or brackets, but perfectly understand when people do so. There are of course other good reasons to use semicolons.

But you can't switch ASI off, so anyways people have to learn about it. Because even with the use of semicolons you will run into things like this.

return
  {
    city: 'London'
  };

The above returns undefined because ASI places a semicolon after the return.

Nowadays there are linters and tools like prettier that can really help with these problems.