|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 .
|
|
#2
|
|||
|
|||
|
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! |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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.
|
|
#6
|
|||
|
|||
|
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. |
|
#7
|
|||
|
|||
|
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.
![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Programming Tools > Article Discussion: The Ultimate JavaScript Guide |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|