From:  Kannan Vijayan <kvijayan@mozilla.com>
Date:  16 Aug 2016 23:14:23 Hong Kong Time
Newsgroup:  news.mozilla.org/mozilla.dev.tech.js-engine.internals
Subject:  

Re: Looking for help on a problem I've found in JS.

NNTP-Posting-Host:  63.245.214.181

Hi Susruthan,

Your code is not producing an error because it is valid code.  Bare braces represent blocks of code.  They don’t always have to have an ‘if’, ‘while’, or ‘for’ statement associated with them.  For example:

    function foo() {
        // some code

        { # block begins here
            // some code
        } # block ends here

    }

This is perfectly valid code, and blocks can be nested arbitrarily deep.  So your code is:

    var a = 1;
    if (a == 1) {
        alert(‘test1’);
    }

    {  # bare block
        alert(‘test2’);
    }

    function test() {
        { # bare block
            { # nested bare block
                alert(‘test3’);
            }
        }
    }

This is valid javascript.

Cheers.
Kannan
    

> On Aug 16, 2016, at 10:51 AM, Susruthan Seran  wrote:
> 
> Hi
> 
> I've found a issue with JS. Today accidentally I put unnecessary curly
> brackets after a if function, but the code is working but not properly.
> Then I tested with several scenario, it's all working without showing any
> error but not properly. I expected to show error for those curly brackets
> but it didn't. I have attached a sample code with this mail. I'm looking
> for some help on this. It's in the syntax or it's a bug, I'm not sure.
> Please have a look..
> 
> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> Regards,
> Susruthan Seran
> _______________________________________________
> dev-tech-js-engine-internals mailing list
> dev-tech-js-engine-internals@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals