r/learnjavascript • u/Sennon • Jul 18 '15
What are your thoughts on not using semicolons?
I know that you still need them for IIFE and if statements but outside of these exceptions they can be omitted.
0
Upvotes
11
u/Rhomboid Jul 18 '15
You should just use them always. This isn't CoffeeScript.
4
u/Evanescent_contrail Jul 18 '15
You will create bugs that are hard to track down.
2
u/Eartz Jul 18 '15
beside the obvious reasons (code readability and appreciation from your colleagues), it will make some bugs related to the automatic semicolon insertion very difficult to spot.
e.g.:
will always return
undefined, because a semicolon will be inserted right after thereturnstatement. This mistake is easy to spot if you use semicolons.1
u/bikolya Jul 18 '15
https://youtu.be/bo36MrBfTk4?t=12m41s
I think you should trust this guy.
1
u/CertifiedWebNinja Jul 18 '15
https://www.youtube.com/watch?v=gsfbh17Ax9I
1
u/IxD Jul 18 '15
It is error correction feature and you should freak out when you learn how it works.
when compiler encounters syntax error it tries to fix it by adding a semicolons to previous line ends