This post originated from an RSS feed registered with Ruby Buzz
by .
Original Post: JavaScript and Semicolons
Feed Title: cfis
Feed URL: http://cfis.savagexi.com/articles.rss
Feed Description: Charlie's Blog
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by
Latest Posts From cfis
Advertisement
Did you realize that semicolons are optional in JavaScript? I have to admit ignorance until just a few weeks ago - and I've been programming JavaScript on and off for seven years. Naturally, when I learned this I went and stripped all the optional semicolons from my code (well, it seemed like a good way to kill a few minutes at the time). It was a bit jarring to see a curly brace language without semicolons. See for yourself1:
It also took a few days to get out of the semicolon habit - although I
still mistakenly put one in here and there (or more commonly name something
like_this instead of likeThis).
So is it worth it? I think so. I fall squarely in the camp that believes
syntax matters - the less of it the better. In fact, I think sparse syntax
plays a significant part in Python's and Ruby's popularity. Granted this change isn't much - but
every little bit counts. Less syntax means less code which means faster
comprehension.