Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 3rd, 2002, 08:08 PM
mytch mytch is offline
Dev Articles Novice (500 - 999 posts)
 
Join Date: Apr 2002
Location: Sydney, Australia
Posts: 589 mytch User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Article Discussion: The Ultimate JavaScript Guide

The Ultimate JavaScript Guide If you have any questions or comments about this article then please post them here. You can read the article here .

Reply With Quote
  #2  
Old December 3rd, 2002, 10:53 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
Finally, just what the struggling javascript neophyte (me) needed - an article that explains the significance of the semi-colon, the difference between = and ==, the impact of capitalization, all in a easily digestible article.

Thanks for the primer!

Reply With Quote
  #3  
Old December 4th, 2002, 08:10 AM
dgibson dgibson is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Urbana, MD, USA
Posts: 66 dgibson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
The semi-colons are entirely optional in JavaScript. It is absolutely preferable to use them for readability, but they aren't required. I don't think you say that they are required, but "JavaScript lines end with a semicolon" sounds pretty close to it.

Reply With Quote
  #4  
Old December 4th, 2002, 07:33 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I didnt know that you didnt have to use ; in javascript?

Oh well im used to programing in PHP, so ill think ill keep with em.

Reply With Quote
  #5  
Old December 5th, 2002, 01:19 PM
dgibson dgibson is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Location: Urbana, MD, USA
Posts: 66 dgibson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
I didn't either, or at least what the compatibility implications were, until not so long ago. I was reviewing code by someone senior to me for debugging purposes and I wondered if the lack of semicolons would have any effect in any browser. I found a blurb somewhere (Which I could not find again for this post) stating that they are optional and the JavaScript parser inserts them on line breaks automatically. (more or less). Still, it was nasty to try to read that code without the semicolons, IMO.

Reply With Quote
  #6  
Old December 6th, 2002, 02:50 PM
beetle18 beetle18 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Victoria, TX
Posts: 29 beetle18 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to beetle18 Send a message via AIM to beetle18
Indeed, semicolons are NOT required to terminate lines of code in Javascript (really, this comes from the ECMAscript spec) as they are required in PHP or other C-based scripting languages. The semicolon is ONLY required when placing multiple operations on a single line

function1(); function2()

We are accustomed to seeing this within event attributes on HTML elements, but it's required anywhere else in javascript code where multiple operations appear on one line.

I personally think that this is something about ECMAscript that should change. First of all, it would liken javascript to all the other C-based scripting languges, so we would have consistency. Second, I agree that it makes the code easier to read. Third, there are cases where a newline DOESN'T actually terminate the line, such as declaring object or array literals, after single operation if statments and loops, etc.

I think it's best not to inform new users of this fact. As Ben pointed out, it's best to use them even though they aren't requried. If you get in the habit of not using them then go code some PHP, watch out, because a missing semicolon there will DESTROY your code

Last edited by beetle18 : December 6th, 2002 at 02:52 PM.

Reply With Quote
  #7  
Old December 20th, 2003, 12:12 AM
Sunshine Sunshine is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: USA
Posts: 1 Sunshine User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question The Ultimate JS guide MIA?

Recently found the devarticles site and have been reading down thru several and found this one but it seems to be MIA. It will only let me see page 1 out of 20 which is just an intro. Has this gem been pulled or what? . I am getting ready to start learning Javascript and this looked like it would have been very helpful since I am studying at home. Many TIA Have a Merry Christmas and Happy New Year's.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Article Discussion: The Ultimate JavaScript Guide


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT