0

I am currently learning Javascript, and there is one element of the syntax that I can just not seem to nail down. That element is adding semicolons at the end of each line. I have learned Python and Ruby, and written a ton of both, so the lack of semicolons is stuck in my mind! Is there a way to drill that (or even any syntax, to make this more useful to future readers) into my brain?

  • Semi colons are completely optional (if you understand ASI) (mislav.uniqpath.com/2010/05/semicolons) – Raynos Apr 12 '12 at 23:04
  • @Raynos not if you want to minify code... – Ben Brocka Apr 13 '12 at 15:22
  • @BenBrocka any non-shitty minifier will insert semi colons for you :\ – Raynos Apr 13 '12 at 15:55
0

No tricks for this I'm afraid. As @Raynos pointed out, semicolons are optional. But if you want to learn the habit in case you might learn other languages that require them, just code slowly and remember it for each line. As you get used to the idea, you'll be able to code faster and it'll become a habit over time.

You'll only get it in the same way you got the habit of not placing any: by "writing a ton of the language".

0

In week #3 and language #3 of CS 103, Comparative Languages, our prof took questions about what problems we were having. Someone said that they couldn't remember which languages had semicolons as separators, and which as terminators. Prof said if you couldn't deal with that, you were gonna fail.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.