Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Question about variables
Isn't it safer to end every statement and variable declaration with a ";" ?
As I watched the video and Jim didn't end the var declaration with a ";" I was surprised that the variable was set to the value he declared and didn't throw an error that it's missing.
Could somebody share some light on this?
I know he stated at the beginning of this course that you don't need to end single line commands but he does advise it.
Isn't it better to end it with a ";" ? mean I've been doing it like this from the starts and I'm just surprised that no error was thrown.
Thanks for the explanation.
Erik Krieg43,038 Points
Including the semicolons at the ends of your lines of code can help reduce the risk of unintended behaviour if that code is compressed. It can also improve readability and promote good habits for coding in other languages, like PHP, which are much more strict about the usage of semicolons.
Thanks for the heads up.
That's why I was a bit surprised. Thank you for your answer and I'll check the link you provided.
True. I think it also defaults to with which programming language you start.
C++ a semicolon maniac.
Python "Whats an semicolon" ;)
But I enjoy learning them all:)