Writing JS file without ;

Discussion in 'Javascript' started by nntp, Oct 28, 2004.

  1. nntp

    nntp Guest

    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.
    nntp, Oct 28, 2004
    #1
    1. Advertising

  2. On Thu, 28 Oct 2004 02:36:03 -0400, nntp <> wrote:

    > 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

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
    Michael Winter, Oct 28, 2004
    #2
    1. Advertising

  3. nntp

    Evertjan. Guest

    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.

    ;-}


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)
    Evertjan., Oct 28, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HNguyen
    Replies:
    4
    Views:
    2,383
    HNguyen
    Dec 21, 2004
  2. Neo Geshel
    Replies:
    6
    Views:
    503
    Neo Geshel
    Feb 14, 2006
  3. Jeevan
    Replies:
    4
    Views:
    492
    Glen Herrmannsfeldt
    Oct 21, 2003
  4. Replies:
    15
    Views:
    1,087
    Keith Thompson
    Mar 14, 2006
  5. Larry
    Replies:
    7
    Views:
    365
    Paul Rubin
    Mar 18, 2008
Loading...

Share This Page