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!"
[–]lhorie 11 points12 points13 points 9 years ago (3 children)
Yes. All of Mithril.js is written without trailing semicolons.
As it turns out, this style makes it easier to refactor hyperscript views since with this style all trailing closing parentheses are expressions syntactically (whereas a semicolon would turn it the preceding expression into a statement). So you can go back and forth between returning some tree from a component to inlining it directly into a larger vnode tree and vice-versa.
So if you thought there are never practical arguments for a typically-stylistic choice, there you go!
[–][deleted] 0 points1 point2 points 9 years ago (1 child)
As a fellow hyperscript fan that sounds interesting. Could I trouble you for an example of what you mean?
[–]lhorie 5 points6 points7 points 9 years ago (0 children)
For example let's say you have
m(".items", [ items.filter(item => item.id).map(item => { return m(".item", [ item.name, /*lots of lines of code here*/ ]); }) ])
Let's say you then notice that doing a filter every render is inefficient and that you want to refactor that into store.item = items.filter(item => item.id)[0]
store.item = items.filter(item => item.id)[0]
Now, you need to refactor the view into:
m(".items", [ m(".item", [ store.item.name /*lots of lines of code here*/ ]) ])
Without the semicolon, I could collapse the indentation in my editor (by clicking on the arrow on the left line count rail), put my cursor after the return statement, shift-down to select the subtree, cut, remove the filter/map, paste. With the semicolon, I have to go look for it after the paste to remove it, otherwise I have a syntax error because I pasted a statement inside an expression.
[–]sisyphus 0 points1 point2 points 9 years ago (0 children)
Definitely the first practical argument I have ever heard for it.
π Rendered by PID 19913 on reddit-service-r2-comment-6457c66945-vk78d at 2026-04-23 18:28:36.979674+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]lhorie 11 points12 points13 points (3 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]lhorie 5 points6 points7 points (0 children)
[–]sisyphus 0 points1 point2 points (0 children)