strenkel / jshero

JS Hero - Learn to code: JavaScript online tutorial with interactive exercises
https://www.jshero.net
Other
28 stars 10 forks source link

Semicolons #24

Open feinstaub opened 6 years ago

feinstaub commented 6 years ago

I remembered reading something that said, one can (and therefore should) omit semicolons at the end of a Javascript code line.

Since jshero does use semicolons, I did a quick research. Examples that recommend no semicolons:

Articles and styles that recommend to use semicolons

The last article complains (among other things) that "Standard JS" is named like this despite the fact that it is only one proposal among others. Interestingly, even in "Standard JS" there is subproject called "semistandard" which adds semicolons to the style (see this page on the bottom).

The conclusion that I draw is that using semicolons is a good thing. Since jshero uses semicolons you probably came to same conclusion. Unless there is something interesting to add about this issue, it could as well be closed. :)

feinstaub commented 6 years ago

Unless there is something interesting to add about this issue

e.g. something to say to students who ask why to use semicolons who figured out that the code works also without them.

strenkel commented 6 years ago

The No-Semicolon position is interesting (never heard before), but I definitely prefer semicolons. The problem is indeed how to teach or explain it. (And there are some more things, that you can code in another way: no 'var'; all statements in one line; no brackets in one line if/for statements; ...) At the moment I have no good solution for this problem.

strenkel commented 6 years ago

Some koans about the optional semikolons should be added!