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 8423285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:41:05+00:00 2026-06-10T03:41:05+00:00

I couldn’t recall the rules for the if statement, so I looked at clause

  • 0

I couldn’t recall the rules for the if statement, so I looked at clause 12.5, but it wasn’t obvious to me still if the curly brace is necessary. So, I ask, where in Ecmascript 5.1 is it mentioned that no left curly brace in an if statement is acceptable?

  • 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-06-10T03:41:06+00:00Added an answer on June 10, 2026 at 3:41 am

    Here is the syntax of an if statement found in section 12.5:

    IfStatement : 
        if ( Expression ) Statement else Statement 
        if ( Expression ) Statement
    

    From the looks of it no curly braces are required but we need to clarify what exactly a statement is. This syntax is found in section 12.

    Statement : 
        Block 
        VariableStatement 
        EmptyStatement 
        ExpressionStatement 
        IfStatement 
        IterationStatement 
        ContinueStatement 
        BreakStatement 
        ReturnStatement 
        WithStatement 
        LabelledStatement 
        SwitchStatement 
        ThrowStatement 
        TryStatement 
        DebuggerStatement 
    

    If we dig a bit deeper into section 12.1 we’ll find the definition of the block statement.

    Block : 
        { StatementListopt } 
    

    We found the curly braces but does this mean they are required? The answer is no. When examining the syntax of a statement each element following the colon is considered a statement and therefore a valid part of the if statement syntax. The following are actual examples of valid if statements.

    // if ( Expression ) ReturnStatement
    if (true) 
        return false;
    
    // if ( Expression ) Block
    if (true) {
        return false;
    }
    
    // if ( Expression ) TryStatement
    if (true) try {
        return false;
    } catch (e) {
        return e;
    }
    
    // if ( Expression ) EmptyStatement
    if (true) ;
    
    // if ( Expression ) IfStatement
    if (true)
        if (false)
            return false;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't find an answer to this question. It must be obvious, but still. I
I couldn't find anything on this, but probably its just because I don't know
Couldn't find similar enough question so I'll ask. I'm trying to use facebook log-in
couldn't find a similar topic but this may boil down to not knowing how
Couldn't find a better place to ask this so I hope you guys can
Couldn't think of a more appropriate question title, but I'm looking for some advice
i couldn't find in one place ,all the Appstore rules for the required images
I couldn't find this in the docs , but how am I meant to
I couldn't find this anywhere, so i thought I'd ask here. Can you do
couldn't find an answer via search (or google) so i'll ask it myself. is

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.