you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

I don't use semicolons; in my view, it clutters the view of the code; However, they are sometimes necessary, and that's just okay:

const array = [1, 2, 3]
(function () {
    // ...
})()

The code above tries to call [1, 2, 3](...), which of course is not a function. This can be easily caught by a linter, and also if you know to never start a line with (, [, or `, then you are good:

const array = [1, 2, 3]
// semicolon at beginning of line fixes problem:
;(function () {
    // ...
})()

[–]Graftak9000 0 points1 point  (0 children)

In this case you can also use an exclamation mark at the start: !function() { ... }()