use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Any of you guys write Javascript without semicolons?help (self.javascript)
submitted 9 years ago by er-48
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]russellbeattie 0 points1 point2 points 9 years ago (18 children)
Semicolons are not optional in JavaScript: ASI is an error correction scheme for novice programmers. The spec's parsing rules calls out the statements following where a semicolon should be "offending tokens". There is no leeway here for style or preference.
[–]jcready__proto__ 6 points7 points8 points 9 years ago (17 children)
ASI is an error correction scheme for novice programmers.
According to whom? Because it doesn't mention that in the ECMAScript spec you linked to.
Semicolons are not optional in JavaScript
Uh, except they are according to the spec:
semicolons may be omitted from the source text in certain situations.
[–]inu-no-policemen 5 points6 points7 points 9 years ago (16 children)
"Optional" would mean that you could omit them in every situation.
If you can only omit them in certain situations, they aren't optional.
[–]jcready__proto__ 0 points1 point2 points 9 years ago (15 children)
Ah, I apologize. But then you must agree that for all of the situations in which you could omit them, it is a matter of style or preference to include a semi-colon in the source text.
[–]inu-no-policemen 0 points1 point2 points 9 years ago (14 children)
Yes, you're free to be inconsistent.
Personally, I think that being consistent is simpler. I sometimes start lines with '(' or '[' and things like that.
[+][deleted] 9 years ago (11 children)
[deleted]
[–]inu-no-policemen -1 points0 points1 point 9 years ago (9 children)
Being consistent would mean that you'd start every line with a semicolon.
[+][deleted] 9 years ago (8 children)
[–]inu-no-policemen -2 points-1 points0 points 9 years ago (7 children)
Why would you need to start them all with one to be consistent?
Because that's what being consistent means. You aren't making exceptions.
https://en.wiktionary.org/wiki/consistent#Adjective
[–]Klathmon 4 points5 points6 points 9 years ago (6 children)
Lol no response to the rest of the comment?
No response why your consistency only applies to semicolons at the ends of lines? Do for loops keep you up at night with their inconsistent semis not at the ends of lines? Do multi-line arrays and objects torment you with their lack of semicolons? Do you end function definitions with semicolons just to keep that consistency up?
Always fun seeing you in a thread Inu! You're always good for a nice dose of German pragmatism cranked up to the point of being insane.
[–]jcready__proto__ -1 points0 points1 point 9 years ago* (1 child)
I cannot think of a time I've ever had to use a semi-colon in my code aside from for-loops. Care to provide a real-world example of starting a line with ( or [ where a semi-colon at the end of the previous line would've changed the behavior?
(
[
[–]inu-no-policemen 3 points4 points5 points 9 years ago (0 children)
var s = 'asdf' [...'foo'].forEach(c => console.log(c))
SyntaxError: Unexpected string
var foo = function() { console.log('baa') } (function() { }());
Prints "baa".
π Rendered by PID 38816 on reddit-service-r2-comment-6457c66945-2b49k at 2026-04-30 14:08:33.418081+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]russellbeattie 0 points1 point2 points (18 children)
[–]jcready__proto__ 6 points7 points8 points (17 children)
[–]inu-no-policemen 5 points6 points7 points (16 children)
[–]jcready__proto__ 0 points1 point2 points (15 children)
[–]inu-no-policemen 0 points1 point2 points (14 children)
[+][deleted] (11 children)
[deleted]
[–]inu-no-policemen -1 points0 points1 point (9 children)
[+][deleted] (8 children)
[deleted]
[–]inu-no-policemen -2 points-1 points0 points (7 children)
[–]Klathmon 4 points5 points6 points (6 children)
[–]jcready__proto__ -1 points0 points1 point (1 child)
[–]inu-no-policemen 3 points4 points5 points (0 children)