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

  • Home
  • SEARCH
  • 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 8291255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:04:20+00:00 2026-06-08T13:04:20+00:00

So pragmatically, I’ve got a quick and dirty answer to what I’m looking for

  • 0

So pragmatically, I’ve got a quick and dirty answer to what I’m looking for here. But why isn’t using that a good idea? Why can’t I find any formal documentation of it? Is it not part of the spec and standard? Is it not widely supported? Is it just because minification could break code using that syntax?

If you could point me to more comprehensive docs of the feature, I’d appreciate that. What defines the contents of the if block? Is it indentation based? If it was, that’d be interesting.

On another note, is there something similar to this syntax for if statements in PHP? I can swear that I’ve seen them being used here and there, but I can’t find any examples off hand. Am I just crazy and it actually doesn’t exist in PHP, or can those types of if blocks be used in PHP? Does such an if block support having an else as well, both in JS and PHP?

It seems that there’s an indentation based one as well as a single-line based syntax as well. What can you tell me about the following?


if(condition) do_some_statement();

Thanks

  • 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-08T13:04:22+00:00Added an answer on June 8, 2026 at 1:04 pm

    But why isn’t using that a good idea?

    Because it’s hard to maintain.

    Why can’t I find any formal documentation of it? Is it not part of the spec and standard?

    Of course it is, see §12.5 – The if Statement and §12 – Statements in the spec. The body of an if is a Statement. One kind of Statement is Block (§12.1), which allows a list of statements to be treated as one statement, but there are many other kinds of statements.

    Is it not widely supported?

    Universally.

    Is it just because minification could break code using that syntax?

    A good minifier won’t break that syntax. (A good minifier will make use of it, in fact.)

    What defines the contents of the if block? Is it indentation based?

    The body of an if statement consists only of the statement following it, indentation has no significance in JavaScript. So all of these are equivalent:

    if (foo)
        bar();
    charlie();
    
    if (foo) bar();
    charlie();
    
    if (foo)
    bar(); charlie();
    
        if (foo)
    bar();
        charlie();
    

    In the above, only the call to bar is conditional on foo; charlie is called regardless.

    That’s why we have Block, the Statement that introduces a list of statements to be treated as a unit (a block, you might say 🙂 ):

    if (foo) {
        bar();
    }
    charlie();
    
    if (foo) { bar(); }
    charlie();
    
    if (foo) {
    bar(); } charlie();
    
        if (foo)
    { bar(); }
        charlie();
    

    Indentation is important for humans, though, so keeping consistent indentation is a good idea. The first example in each of the above is probably clearest (of the ones listed) for us mere mortals. 🙂

    On another note, is there something similar to this syntax for if statements in PHP?

    I’m not a big PHP-head, but it looks identical, defined in Control Structures – if. There are examples with and without {}. (There’s also a different, alternative syntax I won’t go into here.)

    Does such an if block support having an else as well, both in JS and PHP?

    Yes, if supports else both with and without blocks.

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

Sidebar

Related Questions

How can one handle email related communications pragmatically in Erlang/OTP? Using bash, python or
I have this xml file that i have created pragmatically using C# :- <Years>
I have an old redhat 8 box that I need to pragmatically send files
I am looking at History and History JavaDocs in GWT and I notice that
Hi All i am working an callforwarding app. so here my requirement is that
I am trying to pragmatically run a backup of an SQL Server database using
Where can I get best SilverLight 4.0 books that discusses about: How do I
How can I programmatically pause an activity? I have a TabHost that is creating
I have a model User and when I create one, I want to pragmatically
I am still far away from mastering C#, but the child in me 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.