Writing JS file without ;

N

nntp

I wonder what will happen if I do not use ; after each line. Will the code
still run in all browers? I saw some scripts which has lines without ; and
still working perfectly.
 
M

Michael Winter

I wonder what will happen if I do not use ; after each line. Will the
code still run in all browers? I saw some scripts which has lines
without ; and still working perfectly.

ECMAScript defines circumstances where semi-colons are automatically
inserted at the end of a statement, however I personally consider it to be
bad form (and I suspect others will feel the same).

The automatic insertion process is primarily an error-correction
mechanism, used to force certain types of syntax error into something more
acceptable.

I wouldn't advocate intentional omission of terminating semi-colons.

Mike
 
E

Evertjan.

Michael Winter wrote on 28 okt 2004 in comp.lang.javascript:
I wouldn't advocate intentional omission of terminating semi-colons.

The semicolon is an ECMA-unintentional marker for showing a code line is
not vbscript.

;-}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top