Closing each code line


Is it absolutely necessary for me to put a ";" at the end of each code line in order for the code to work?


Read Automatic semicolon insertion in
the =Book=

=discussions / opinions=
google search
javascript semicolon necessary


If you don't put it in it will be automatically inserted for you where the interpreter "thinks" you'd like it to have been. This can sometimes produce unintended results especially for beginners.

When you get very comfortable with the language and are familiar enough with the interpreter to let it take care of your semi's then go for it. Until then it's probably a good idea to use semi-colons since they'll have to be in your code one way or another.

As with most things there are strong feelings out there regarding semi colons in JS. Some of the more prominent speakers on the subject have differing views so you're validated no matter what you do so long as you do it deliberately, consistently, and with understanding.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.