IIAFEs?

Brandon Benvie bbenvie at mozilla.com
Sat Jun 1 16:59:03 PDT 2013


On 6/1/2013 4:52 PM, Jorge wrote:
>
> What might happen with this is that if you concatenate a bunch of .js files that use this pattern, they might end redefining the same label (which would be an error, I guess).
You can only break a block that you're currently in. So this is fine:

     block: {
       break block;
     }
     block : {
       // whatever
     }

There's no conflict; this is perfectly valid. You would only run into an 
issue if the code was being wrapped in some outer block that was named 
the same, and there's no reason that would happen.


> But then... I'm not sure this is any better than an IIFE!

It's certainly more ugly. It can be more performant because a block 
scope is lighter than creating a new function and then executing it, but 
most IIFEs are only executed once so it doesn't matter. The option is 
there, though.


More information about the es-discuss mailing list