7 ms·
Personally I think the Google Javascript Style Guide has it right: > Relying on implicit insertion can cause subtle, hard to debug problems. Don't do it. You'r
by felixge 16y ago
Personally I think the Google Javascript Style Guide has it right:
> Relying on implicit insertion can cause subtle, hard to debug problems. Don't do it. You're better than that.
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Semicolons#Semicolons http://google-styleguide.googlecode.com/svn/trunk/javascript...
- uptown 16y agoInteresting that you use Google as the example for always using semi-colons with JavaScript. When writing a code-example on a white-board during my Google interview, I was using semi-colons throughout my code. One of the things the interviewer asked was why I was using semi-colons ... implying that my code wasn't as clean as it could be. We talked about whether they were needed or not, but his preference seemed to be that they weren't really necessary, and that I shouldn't have been including them in my code. I continue to use them in my code.
- yock 16y agoPerhaps your interviewer asked the question to see if you could justify them, thus gauging your understanding of how the language is parsed at runtime. The fact that the conversation continued may indicate that he or she wasn't convinced by your answer?
- dazzawazza 16y agoI think this is more likely. When interviewing the point is to find out how someone is thinking not if they agree with a coding standard.
- uptown 16y agoQuite possible. It wasn't a turning-point in the interview or anything ... but a discussion that lasted longer than I would have expected given the topic.
- mrfish 16y agoDid you get the job?
- felixge 16y agoFWIW: I would like to not use semicolons in JS. But the current "push" for that is IMHO a mix of ruby/python home sickness and "Let's do this because we are smart enough to do it right.". Both are terrible influences on style in any language.
- mathgladiator 16y agoI once wrote a tool to beautify javascript from a mangled/compress form and in doing so learn that implicit insertion is absolute evil. return { a : true } and return { a : true } are different and can cause many problems.