why do some lines of javascript code have ";" at the end.
Printable View
why do some lines of javascript code have ";" at the end.
else you get an error :D
it's to close the 'function'
I wrote the following and removed all the ";" and it didnt error at all
does anyone else know what the semi-colons are for?VB Code:
<script language="JavaScript"> function checker(){ var complete = "F" ; var message = "" ; var error = "" ; var acc_count = 0 ; var text = "" ; for (i = 1; i <= count; i++){ dave = eval("document.pc_app.F_PROF_"+i) ; if (dave[0].checked || dave[1].checked || dave[2].checked || dave[3].checked){ complete = "T" ; }else{ message = message + (i + " ") ; error = "Y" ; } } for (i = 1; i <= count; i++){ dave1 = eval("document.pc_app.F_PROF_"+i) ; if (dave1[3].checked){ acc_count = acc_count + 1 ; } } if (acc_count == count){ complete = "F" ; text = "You have selected 'No Access' for\nevery module. Please try again." ; } if (error == "Y"){ complete = "F" ; text = ("Please select an ability profile\nfor module(s): " + message) ; } if (complete == "F"){ alert(text) ; return false ; }else{ return true ; } } </script>
in JAvascript, they indicate the EOL or end of the line.... some languages live VB use the CRLF as the EOL.... most other languages use ; .....
Did it work at all?Quote:
Originally posted by davebat
I wrote the following and removed all the ";" and it didnt error at all
In JS, ; is the EOL marker. Nothing magical or extra.
in a lot of languages they use ; , not just JS
More accurately it is a statement terminator. In JavaScript a newline is also a statement terminator. The only time a semi-colon is required is if you wanted to put two statements on the same line. e.g.,Quote:
In JS, ; is the EOL marker
Code:x += 2; y -= 1