Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6208925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:53:26+00:00 2026-05-24T05:53:26+00:00

I have seen and used javascript code that both has and omits the ‘;’

  • 0

I have seen and used javascript code that both has and omits the ‘;’ from the end of statements. Are they required in some cases and not in others? If so can you give some examples, and if not what is the general standard, to use the ‘;’ or to not…that..is the question??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:53:27+00:00Added an answer on May 24, 2026 at 5:53 am

    JavaScript uses a (generally disliked) method called Semicolon Insertion, where it will allow you to omit semicolons.

    The rules for where you can and cannot insert semicolons is extensive, and covered fairly well here.

    In general, do not rely on semicolon insertion. It is a poorly thought out feature and will hurt you before it helps you.

    Not only should you always use semicolons, but you should also get in the habit of putting your { braces on the same line, as semicolon insertion can actually misinterpret what you meant.

    For example, say I’m trying to return a javascript object from a function:

    function f() {
        return { "a":"b", "c":"d" }    // works fine
    }
    
    function g() {
        return                         // wrong!!!
        {
            "a":"b",
            "c":"d"
        }
    }
    

    If I put the { on a new line (as I did in g), the return statement will actually have a semicolon inserted after it, destroying the meaning of what you were saying.

    Overall, semicolon insertion is a poor feature and you should never rely on it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen (and used) code to have a link spawn a javascript action many
In javascript I have seen i++ used in many cases, and I understand that
If you've used Google Wave or iGoogle you have probably seen that you can
I've seen in a few iPhone examples that attributes have used an underscore _
I have seen the following methods of putting JavaScript code in an <a> tag:
I have seen the following href used in webpages from time to time. However,
I'm new to building jQuery plugins. I have seen and used a lot of
I have seen two commonly used techniques for adding the directory of the file
I have seen bind and eval used interchangeably especially in ASP.NET GridViews. What is
I have seen these two approaches for constant declaration which are to be used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.