Writing JS file without ;

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nntp

    #1

    Writing JS file without ;

    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.


  • Michael Winter

    #2
    Re: Writing JS file without ;

    On Thu, 28 Oct 2004 02:36:03 -0400, nntp <nntp@rogers.co m> wrote:
    [color=blue]
    > 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.[/color]

    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.

    Comment

    • Evertjan.

      #3
      Re: Writing JS file without ;

      Michael Winter wrote on 28 okt 2004 in comp.lang.javas cript:[color=blue]
      > I wouldn't advocate intentional omission of terminating semi-colons.[/color]

      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)

      Comment

      Working...