Stevo said the following on 12/2/2007 2:00 PM:
Randy Webb wrote:
>Are you sure the UA supports .getElementById, .style, and .visibility? :)
Unless the user is using a 1995 Browser then yes ;-)
I was kidding, but, you should read back on some threads about my cell
phone browser. Screw ball browser to say the least. I did like your
improvement over the code I posted though.
>I won't comment on the semi-colons as I don't want to have the debate
again. They aren't required, and can even cause harm if you don't know
for sure where to put them.
Same applies to spaces, commas, parentheses and quotes.
Examples of what you are referring to with spaces, commas, parentheses
and quotes?
Why are semi-colons different?
Typically, the issue with semi-colons is the same issue that JSLint will
throw at you if you don't have statement ending semi-colons which are
optional. If you aren't sure one should be there, leave it out. The
parser is going to double-check you anyway and if it wants/needs one, it
will add it. Whether you put it there or not.
There is an old thread somewhere in the archives where I asked if
anybody could post code where the lack of a semi-colon changed/altered
the code.
<URL:
http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/7bb42992e6b6e5/62200f04774ca73f?lnk=gst&q=statement+semi-colon+randy+webb#>
Maybe you can give a real world example of the semi-colon making a
difference - other than minimization of code.
If you don't put them on, then you can forget about your code
ever being minimized. I used to always drop trailing semi-colons
until the day came when I wanted to minimize some code.
Minimizing code has nothing to do with writing "valid code" though. It
is related to something else - file size. Even then, you are only saving
one byte per line. How much difference that one byte makes depends on
the length of your statements. 1 character off of a 30 character line
isn't a whole lot of savings. Just gzip and go on with it :)
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/