NEWBIE: Ending lines with a semicolon.

Giganews Newsgroups
Subject: NEWBIE: Ending lines with a semicolon.
Posted by:  varois…@netzero.net (Patrick)
Date: 6 Jul 2003

Hi

I am in the process of learning javascript.How come i am being told to
always finish my lines with a semicolon and when i try the 2 following
pieces of code they give the same output which is printing "Hello
world!" to the document.
The second example doesn't have the semicolon, why doesn't the browser
throw an error message?

<SCRIPT TYPE="text/javascript">
document.write("Hello world!"); //Semicolon present
</SCRIPT>

<SCRIPT TYPE="text/javascript">
document.write("Hello world!") //Semicolon missing
</SCRIPT>

Thanks to all

Patrick
(Please answer here or email vaindio…@NOSPAMyahoo.com and remove
NOSPAM.I don't read the address used to post.)

Replies