Real World Func Decl in Block Scope Breakages

Brendan Eich brendan at mozilla.com
Wed Dec 26 17:59:44 PST 2012


Brandon Benvie wrote:
> This appears to be correct. A number of the examples can be boiled 
> down to the following test:
>
>     if (false) {

No, the working examples in Brian's snippets rather test an always-true 
condition. That means they work in Firefox too.

/be

>         function x(){
>           console.log('worked');
>         }
>     }
>     x();
>
>
> In Chrome, IE, Opera, and Safari 'worked' will be logged. In Firefox 
> it will silently fail.
>
>
> On Wed, Dec 26, 2012 at 5:22 PM, Allen Wirfs-Brock 
> <allen at wirfs-brock.com <mailto:allen at wirfs-brock.com>> wrote:
>
>     Essentially only,  uses of this form are currently interoperable
>     among all major implementations:
>
>     if (condition) {
>          function foo() {};
>          foo();   //function declared and invoked in same conditional
>     blocks.
>     }
>
>     Other uses (without other explicit feature or browser detection
>     logic being involved) are not likely to be interoperable.
>
>     I haven't looked in detail at all of Brian's snippets.  But
>     several that I have glanced at look to me like they wouldn't be
>     interoperable among current browsers.
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list