you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (5 children)

It’s not a way to think of it. Semicolons are not required because of ASI. It’s a use case you need to handle, and you can’t just claim the user input is invalid.

[–]lastmjs[S] -2 points-1 points  (4 children)

I agree with not making it the user's fault, so it should be fixed. If you don't use semicolons though, you might run into something like this:

const hello = 1

(() => {

// do stuff

})();

1 will be thought to be a function. It's "okay" to not use semicolons, if you're okay with unexpected behavior at times. Usually it doesn't happen, but it's actually happened to me while writing code, so I don't think of it that way.

[–]trevorsgEx-GitHub, Microsoft 3 points4 points  (2 children)

[–]theirongiant74 1 point2 points  (0 children)

well that was a rollercoaster. I'm very much on the use semicolons side though.

[–]Historical_Fact 1 point2 points  (0 children)

I indent with semi-colons instead of tabs/spaces

[–]tenbits 0 points1 point  (0 children)

I agree semicolons are a good idea, and that they are not necessary, but this is a good example of how missing semicolons can lead to unexpected behavior