Is semicolon needed in Java Script? horror of ;

Short answer is NO in recent times, here is why
The semicolon is used to separate statements, but it can be omitted if the statement is followed by a line break.
The semicolon is needed, only when you have two or more statements on the same line, not other wise 🙂 

    var i = 0; i++        // <-- semicolon obligatory
                          //     (but optional before newline)
    var i = 0             // <-- semicolon optional
        i++               // <-- semicolon optional

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.